我使用 XlsxWriter python 包从我的数据中生成一个 excel 文件。我尝试了几种方法将我的字体“B Nazanin”应用于单元格:
title_cell_format.set_font_name('B Nazanin')
title_cell_format.set_font_family('B Nazanin')
title_cell_format.set_font('B Nazanin')
当我使用其中一种方法时,我可以看到字体名称,但字体外观不像输出 excel 文件中的“B Nazanin”:
我猜想解决方案应该是在下面的菜单中设置可以在 excel 中手动完成的文本方向。现在的问题是如何在我的 python 程序中设置这个属性!!
最佳答案
它没有记录,主要是因为没有人要求它,但您可以使用格式设置单元格文本方向 reading_order
属性(property)。
从右到左是阅读顺序 2:
title_cell_format.set_reading_order(2)
更新 :
此问题与 reading_order/text 方向无关。看起来它更有可能与这种特定字体的字符集有关。以下需要来自 GitHub 的最新 XlsxWriter 代码,但应该可以解决该问题:
title_cell_format.set_font('B Nazanin')
title_cell_format.set_font_family(0)
title_cell_format.set_font_charset(178)
关于excel - python XlsxWriter : set font does not affect the appearance of cells in output excel file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34072320/