gpt4 book ai didi

python - 有没有一种方法可以在不将数据写入工作表中的单元格的情况下在 XlsxWriter 中创建图表? IE。来自 python 脚本中的数组?

转载 作者:太空宇宙 更新时间:2023-11-04 04:09:27 25 4
gpt4 key购买 nike

我的目标是在 XlsxWriter 的工作表中创建一个图表,而图表中的数据在工作表的任何位置都可用(我不想引用单元格)。由于法律原因,书中无法提供数据。

或者,如果有一种方法可以将数据写入单元格,将该数据绘制成图表,然后删除单元格引用,这样我就可以获得一个不引用单元格的图表,我也会对此持开放态度。我知道有一些方法可以在 excel 中完成此操作。

我尝试用整数列表(我想要绘制图表的数据)替换“类别”和“值”参数,但由于缺少单元格引用而出现错误。 (见下面的功能)。

# Builds a chart with top left corner at row_start, col_start (zero 
# indexed).

# data[data_input[i][0]]['history'][0] is a list of dates.
# data[data_input[i][0]]['history'][1] is a list of values for those dates.

chart = workbook.add_chart({'type': 'line'})

for i in range(len(data_input)):
chart.add_series({
'name': title,
'categories': data[data_input[i][0]]['history'][0],
'values': data[data_input[i][0]]['history'][1],
'line': {'color': colors[i], 'width': 1}
})

worksheet.insert_chart(row_start, col_start, chart)

TypeError: xl_range_formula() 接受 5 个位置参数,但给出了 261 个

最佳答案

My goal is to create a chart in a sheet from XlsxWriter without having the data from the chart available anywhere on the sheet. For legal reasons the data cannot be available in the book.

那是不可能的。

在 Excel 中,可以根据您直接在数据对话框中提供的数据绘制图表,而无需引用单元格。但是,XlsxWriter 不支持该选项,并且它也不会以任何方式隐藏您的数据,因为任何人都可以进入对话框并查看数据。此外,任何人都可以解压缩文件并查看数据。

此外,任何人都可以将鼠标悬停在图表中的数据上并查看生成图表的值。

Alternatively, if there's a way to write data to cells, graph that data, and then remove the cell references so I can have a graph that isn't referencing cells,

不,原因同上。

退后一步,尝试弄清楚您想要做的事情是否可以仅在 Excel 中以任何方式实现(可能是通过隐藏包含源数据的工作表,然后锁定文件并使用密码保护文件)。如果有一种方法可以在 Excel 中执行此操作,那么您就知道要问有关如何在 Python 中执行此操作的问题了。

作为建议,一种方法是创建图表图像并将其插入到 Excel 中。这样就没有原始数据的链接。

关于python - 有没有一种方法可以在不将数据写入工作表中的单元格的情况下在 XlsxWriter 中创建图表? IE。来自 python 脚本中的数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56600604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com