有没有办法在 XlsxWriter 中创建图表而不将数据写入 sheet 中的单元格? IE。来自 python 脚本中的数组?
Is there a way to create a chart in XlsxWriter without writing the data to cells in a sheet? IE. From an array in the python script?
我的目标是从 XlsxWriter 在 sheet 中创建一个图表,而 sheet 上的任何地方都没有图表中的数据(我不想引用单元格)。由于法律原因,书中无法提供数据。
或者,如果有一种方法可以将数据写入单元格,将该数据绘制成图表,然后删除单元格引用,这样我就可以获得一个不引用单元格的图表,我也会对此持开放态度。我知道在 excel.
中有一些方法可以实现这一点
我尝试用整数列表(我想要绘制的数据)替换 'categories' 和 'values' 参数,但由于缺少单元格引用而出现错误。 (见下面的函数)。
# 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。这样原始数据就没有link了。
我的目标是从 XlsxWriter 在 sheet 中创建一个图表,而 sheet 上的任何地方都没有图表中的数据(我不想引用单元格)。由于法律原因,书中无法提供数据。
或者,如果有一种方法可以将数据写入单元格,将该数据绘制成图表,然后删除单元格引用,这样我就可以获得一个不引用单元格的图表,我也会对此持开放态度。我知道在 excel.
中有一些方法可以实现这一点我尝试用整数列表(我想要绘制的数据)替换 'categories' 和 'values' 参数,但由于缺少单元格引用而出现错误。 (见下面的函数)。
# 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。这样原始数据就没有link了。