2021年3月3日星期三

Python openpyxl Table Styling convert table to range

I generate this spreadsheet via python and pandas. After generating the .xlsx file, i would go into Excel and format it using the table Format as table button on the main ribbon.
I decided that i didn't want to manually format the spreadsheet so I started using Openpyxl to attempt to mimic my formats.

my main hiccup is that after i use the format as table button

I would then click on Convert to Range.

The problem is, i cant seem to be able to do this using openpyx.

Does anyone know how to do this? I don't want to create my own personalized style if one already exists. this is the code i have been using

tab = Table(displayName="Final', ref='A1:O34', tableType=None)    style = TableStyleInfo(name="TableStyleLight2", showFirstColumn=False,  showLastColumn=False, showRowStripes=True, showColumnStripes=False)  tab.tablestyleInfo = style  ws.add_table(tab)  wb.save()  

Very basic and to the point, more or less copied from teh openpyxl documents.

How do i convert this table to a range of values from openpyxl

thanks

Damn Groundhog

https://stackoverflow.com/questions/66394676/python-openpyxl-table-styling-convert-table-to-range February 27, 2021 at 09:12AM

没有评论:

发表评论