问题
I have added new sheet to existing excel sheet using Python xlwings. I want to set row height to 15 in new sheet. How can I do that.?
回答1:
As explained under Missing Features, you can always drop down to pywin32 and check out the documentation for VBA.
In your case, it would work like this:
import xlwings as xw
wb = xw.Book(...)
wb.sheets[0]['1:1'].api.RowHeight = 100
回答2:
there is no way till now you can do it in xlwings but if you're okay to do it with openpyxl here 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')
来源:https://stackoverflow.com/questions/60520200/how-to-set-row-height-using-python-xlwings