pycel 输出一个空 cell_map 的 yaml 文件
pycel outputs a yaml file with empty cell_map
代码:
from pycel import ExcelCompiler
file = 'test.xlsx'
excel_compiler = ExcelCompiler(file)
excel_compiler.to_file(file + ".yaml")
输出:
cycles: false
excel_hash: 50c4cf43c7d0ba6fe6ee608b6deebab2
cell_map: {}
filename: test.xlsx
问题是:test.xlsx 有 A: 13
、B: 23
和 C: =A+B
为什么 cell_map
是空的?
Pycel 不会输出整个电子表格。它输出电子表格的“有趣”部分。
如何指出电子表格中有趣的部分。
Pycel 构建参与计算的单元格图。该图是在“编译”单元格的过程中构建的。如果某个单元格的公式包含对其他单元格的引用,则这些单元格也会添加到图表中。这个过程是递归的,需要用感兴趣的细胞作为种子,才能知道要编译哪些细胞。
在example代码中,显示了两种在pycel中“填充”计算图的方法。
评估一个单元格,将其添加到计算图中
excel.evaluate('Sheet1!D1')
用trim_graph()
显式填充计算图
# As an alternative to using evaluate to put cells in the graph and
# as a way to trim down the size of the file to just that needed.
excel.trim_graph(input_addrs=['Sheet1!A1'], output_addrs=['Sheet1!D1'])
免责声明:我是 Pycel 的维护者
代码:
from pycel import ExcelCompiler
file = 'test.xlsx'
excel_compiler = ExcelCompiler(file)
excel_compiler.to_file(file + ".yaml")
输出:
cycles: false
excel_hash: 50c4cf43c7d0ba6fe6ee608b6deebab2
cell_map: {}
filename: test.xlsx
问题是:test.xlsx 有 A: 13
、B: 23
和 C: =A+B
为什么 cell_map
是空的?
Pycel 不会输出整个电子表格。它输出电子表格的“有趣”部分。
如何指出电子表格中有趣的部分。
Pycel 构建参与计算的单元格图。该图是在“编译”单元格的过程中构建的。如果某个单元格的公式包含对其他单元格的引用,则这些单元格也会添加到图表中。这个过程是递归的,需要用感兴趣的细胞作为种子,才能知道要编译哪些细胞。
在example代码中,显示了两种在pycel中“填充”计算图的方法。
评估一个单元格,将其添加到计算图中
excel.evaluate('Sheet1!D1')
用trim_graph()
显式填充计算图
# As an alternative to using evaluate to put cells in the graph and
# as a way to trim down the size of the file to just that needed.
excel.trim_graph(input_addrs=['Sheet1!A1'], output_addrs=['Sheet1!D1'])
免责声明:我是 Pycel 的维护者