I am using python's xlsxwriter package to format the excel report that I am generating through a mysql query.
The problem is that the report generated by sql the returns the columns dynamically so their is no way of knowing how many column will be returned before hand. I am trying to set border only to the returned number of columns. But so far I am only able to hard code the number of columns(A:DC). Can anyone help me with this, I am using the following query-
worksheet = writer.sheets['Sheet1']
formater = workbook.add_format({'border':1})
worksheet.set_column('A:DC',15,formater)
writer.save()
Set the range dynamically based on the length of the data you receive
data = [...]
worksheet.set_column(0, len(data), 15, formater)
set_column()
docs for the reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With