We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
你尝试过ElementTree吗?如果使用太多内存,请使用 SAX 并一次只处理一行。 XML 解析 - ElementTree 与 SAX 和 DOM
have you tried ElementTree? if that uses too much memory, use SAX and just process a row at a time. XML parsing - ElementTree vs SAX and DOM
XLSX 格式由许多已压缩的 XML 文件组成。如果输出的格式不会改变,那么使用现有文件作为模板并根据需要简单地向其中添加行将是微不足道的。不幸的是
ZipFile.writestr
没有不允许您分段写入文件,因此您必须将整个 XML 写入临时文件,然后使用 ZipFile.write 将其放入 zip 中。The XLSX format consists of a number of XML files that have been zipped. If the format of the output will not be changing, it would be trivial to use an existing file as a template and simply add rows to it as necessary. Unfortunately
ZipFile.writestr
doesn't allow you to write the file in pieces, so you'll have to write the entire XML to a temporary file then place that into the zip withZipFile.write
.