我已使用Python xlwings向现有的Excel工作表中添加了新工作表。我想在新表中将行高设置为15。我该怎么办。?
到目前为止,您无法在xlwings中完成此操作,但是如果可以,可以使用openpyxlhere is the link for better understanding
# import openpyxl module
import openpyxl
# Call a Workbook() function of openpyxl
# to create a new blank Workbook object
wb = openpyxl.Workbook()
# Get workbook active sheet
# from the active attribute.
sheet = wb.active
# writing to the specified cell
sheet.cell(row = 1, column = 1).value = ' hello '
sheet.cell(row = 2, column = 2).value = ' everyone '
# set the height of the row
sheet.row_dimensions[1].height = 70
# set the width of the column
sheet.column_dimensions['B'].width = 20
# save the file
wb.save('dimension.xlsx')
如Missing Features中所述,您始终可以下拉至pywin32并签出documentation for VBA。
在您的情况下,它将像这样工作:
import xlwings as xw
wb = xw.Book(...)
wb.sheets[0]['1:1'].api.RowHeight = 100