python - 使用 XlsxWriter 将文本框或文本框中的文本定向为垂直?

标签 python xlsxwriter

我找不到如何在文本框中设置文本垂直方向的示例

我找到了如何旋转单元格中的文本,但我需要旋转文本框中的文本

文本框代码

text = 'Some text in a textbox'
options = {
'font': {'color': 'white'},
'align': {'vertical': 'middle',
           'horizontal': 'center',
          },
'gradient': {'colors': ['red', 'blue']},
}
worksheet.insert_textbox(row, col, text, options)

单元格中带有旋转文本的代码

cell_format = workbook.add_format()
cell_format.set_rotation(90)
worksheet.write(1, 1, 'This text is rotated')
worksheet.set_column(col, col, None, cell_format)

最佳答案

这不是当前可用的功能,但如果您打开 Feature Request on GitHub我可以添加它。

更新:现在在 XlsxWriter >= 1.2.4 中可用。

来自更新的docs :

The text_rotation option can be used to set the text rotation for the entire textbox:

    worksheet.insert_textbox('B2', 'Text rotated up',
                             {'text_rotation': 90})

enter image description here

关于python - 使用 XlsxWriter 将文本框或文本框中的文本定向为垂直?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56818434/

相关文章:

Python:有策略地遍历 0-9 的十位数字

python - 修改数据框行 - Panda Python

python - 通过 Binary Copy 将包含 PostGis 字段的数据批量加载到 PostgreSQL

python - 哪些字符对 Excel 单元格(xlsx 文件格式)调用 alt+enter? (wrap_text 不起作用)

python - Pandas 无法在索引 0 处添加列

python - 使用 xlsxwriter 设置 Excel 大纲选项

python - xlsxwriter 图表类别文件大小

python - 如何测试 Python 中缺少特定库的情况

python - 如何将数据帧列表从 R 导出到 Python?

python - 在 Excel 中的不同单元格范围上应用条件格式 (XlsxWriter)