I am using a library called xlsxwriter in python for creating a Excel file. I am using 'set_indent' to use indentation before my text in a cell, but i am not sure why it's not working.
Code:-
workbook = xlsxwriter.Workbook("Example.xlsx")
worksheet = workbook.add_worksheet("My_Sheet")
cell_indent_format = workbook.add_format().set_indent(2)
worksheet.write('B20', "HELLO", cell_indent_format)

It should work. Just split out the method calls:
import xlsxwriter
workbook = xlsxwriter.Workbook("Example.xlsx")
worksheet = workbook.add_worksheet("My_Sheet")
cell_indent_format = workbook.add_format()
cell_indent_format.set_indent(2)
worksheet.write('B20', "HELLO", cell_indent_format)
workbook.close()
Output:

I thought I had the same issue, but actually my issue was the inability to use this in conditional formatting. In the normal cell formatting it worked though.
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