我试图使用以下代码将字典写入.xlsx文档:
example_dict = {"Column 1": [1, 2, 3], "Column 2": [4, 5, 6], "Column 3": [7, 8, 9]}
cont = pyexcel.utils.dict_to_array(example_dict)
sheet = pyexcel.Sheet(cont)
sheet.save_as("output.xlsx")代码参考http://docs.pyexcel.org/en/v0.1.1/tutorial.html#writing-a-single-sheet-excel-file。
我得到了错误AttributeError:‘模块’对象没有属性'utils‘。
确切地说,我试图将键条目填充到列中,而不是行(按行填充是默认的方式)。到目前为止,我还没有发现任何有帮助的地方,我非常感谢在修复错误方面的任何帮助。
发布于 2022-01-28 15:11:14
您已经链接到了pyexcel文档的一个非常旧的版本(v0.1.1)。您可能正在使用较新的版本。
当前版本的文档 (v0.7.0)给出了完成相同任务的以下示例:
a_dictionary_of_one_dimensional_arrays = {
"Column 1": [1, 2, 3, 4],
"Column 2": [5, 6, 7, 8],
"Column 3": [9, 10, 11, 12],
}
sheet = pyexcel.get_sheet(adict=a_dictionary_of_one_dimensional_arrays)
sheet.save_as("output.xlsx")https://stackoverflow.com/questions/70895835
复制相似问题