我正在使用模块xlsxwriter来生成示例报告,我想添加图形文本来对其进行签名。像这样:
我已阅读 Xlsxwriter 网站上的文档,但我找不到任何设置透明度的解决方案(我的意思是您可以看到字符 l 下方的 数量)和旋转文本。有人对这个案例有什么想法吗?
最佳答案
您可以通过关闭实心填充和边框来设置 XlsxWriter 中文本框的透明度。这是一个例子: 导入xlsxwriter
workbook = xlsxwriter.Workbook('textbox.xlsx')
worksheet = workbook.add_worksheet()
# Set the column wider for clarity.
worksheet.set_column('A:A', 60)
# Add some sample text.
for row in range(10):
worksheet.write(row, 0, "Here is some text in the background")
# Set the textbox options.
options = {
'width': 500,
'height': 100,
'font': {'italic': True,
'color': '#DDDDDD',
'size': 60},
'fill': {'none': True},
'line': {'none': True},
}
# Insert the textbox over the cell text.
worksheet.insert_textbox('A3', 'Sample Report', options)
workbook.close()
输出:
请参阅Working with Textboxes XlsxWriter 文档部分。
但是,我认为在 Excel 中不可能旋转文本框中的文本(垂直和上/下旋转除外)。在 Excel 中旋转一定角度的选项呈灰色。
我认为您帖子中的图像可能是使用艺术字实现的,XlsxWriter 不支持艺术字。
关于graphics - 如何使用 xlsxwriter 在文本框中放置一些具有透明度和旋转的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44917147/