英文:
Changing Format in XLSX file created using XlsxWriter module
问题
I understand you want the code part to be translated. Here's the translated code:
# 测试表格
# 格式
_format = workbook.add_format({'top': True, 'bottom': True, 'right': True, 'left': True})
_era.to_excel(writer, sheet_name='Test', header=False, index=False, startcol=2, startrow=2)
workbook = writer.book
worksheet = writer.sheets['Test']
worksheet.hide_gridlines(2)
worksheet.conditional_format(2, 2, 20, 11, {'type': 'no_blanks', 'format': _format})
If you have any more code to translate or need further assistance, please let me know.
英文:
I'm trying to change the format in an excel file that has been created using the XlsxWriter module in Python, but so far I haven´t been able to do it. Whenever I open the file in Excel and try to change the border formats nothing happens.
The code I´m using is doing what it is supposed to:
#Test Sheet
#Format
_format = workbook.add_format({'top':True, 'bottom': True, 'right': True, 'left': True})
_era.to_excel(writer, sheet_name='Test', header=False, index=False, startcol = 2, startrow = 2)
workbook = writer.book
worksheet = writer.sheets['Test']
worksheet.hide_gridlines(2)
worksheet.conditional_format(2, 2, 20, 11, {'type': 'no_blanks', 'format': _format})
The Output:
But afterwards, when I try to change the cell borders format in Excel, nothing happens, it stays the same:
And the result is the exact same thing I downloaded in the first place:
I've tried lots of things, but I must be missing something regarding the code I´m using, is there somebody willing to help?
Cheers.
答案1
得分: 2
这是发生的原因是因为数据网格正在使用条件格式进行格式化,这会覆盖后来应用于单元格的任何手动边框格式。
这与XlsxWriter无关。在Excel中创建的文件也会出现这种情况。
英文:
The reason this is happening is because the data grid is being formatted with a conditional format and that overrides any manual border format that is later applied to the cells.
This isn't related to XlsxWriter. It would also happen with a file created in Excel.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论