如何使用python-xlsxwriter从excel文件上的单元格中删除绿色箭头? [英] How can I remove the green arrow from a cell on excel file using python-xlsxwriter?

查看:95
本文介绍了如何使用python-xlsxwriter从excel文件上的单元格中删除绿色箭头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编写一个带有百分号的值时,excel在该单元格的顶部向我显示一个绿色箭头.

When i wrote a value that does have a percentage sign, excel shows me a green arrow on the top of that cell.

这就是我用来在特定单元格中写入值的方法.

This is what I use to write a value in a specific cell.

worksheet.write(1, 46, '12%')

我尝试过这个:

worksheet.write_string(1, 46, '12%')

还有这个

worksheet.write_number(1, 46, '12%')

但是我得到相同的结果.

but I get the same results.

如何摆脱绿色箭头?

谢谢!

推荐答案

绿色箭头/三角形是Excel警告.可能是有关数字存储为文本的警告.

The green arrow/triangle is an Excel warning. It is probably the warning about numbers stored as text.

避免这种情况的方法是不带百分比的数字写入数字,然后以数字格式对其进行格式化,以便显示百分比符号.这通常是在Excel中完成的方式.

The way to avoid this is to write the number without the percentage and then format it with a number format so that the percentage sign is displayed. That is how it is generally done in Excel.

使用XlsxWriter,您可以执行以下操作:

With XlsxWriter you can do it as follows:

import xlsxwriter

# Create a new workbook and add a worksheet.
workbook = xlsxwriter.Workbook('percent.xlsx')
worksheet = workbook.add_worksheet()

# Create a percentage number format.
percent_format = workbook.add_format({'num_format': '0%'})

# Write a number as a percentage.
worksheet.write('A1', .12, percent_format)

workbook.close()

这篇关于如何使用python-xlsxwriter从excel文件上的单元格中删除绿色箭头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆