excel - python XlsxWriter : set font does not affect the appearance of cells in output excel file

标签 excel python-3.x fonts xlsxwriter

我使用 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”:enter image description here

我猜想解决方案应该是在下面的菜单中设置可以在 excel 中手动完成的文本方向。现在的问题是如何在我的 python 程序中设置这个属性!!
enter image description here

最佳答案

它没有记录,主要是因为没有人要求它,但您可以使用格式设置单元格文本方向 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/

相关文章:

excel - 如何使用 Excel 公式将一个工作表中的单元格范围引用到另一个工作表?

excel - 将 Excel 工作表导入 Postgresql 数据库

python - Python3 中 random.choice(list) 的大 O 复杂度

python - 如何将 jupyter 内核从 Python 2 更改为 python 3?

ios - Cookies.ttf 字体不能在 iOS 应用程序中使用?

java - Apache POI 设置日期格式并不总是在 Excel 中正确格式化

由于重复值,Excel小公式不返回小值

python - 用 python 和 re 清理文本

css - 如何让 'font-weight: lighter' 在 Google Chrome 中工作?

html - 字体不会在输出中改变