Open Office如何压缩其文件? [英] How does Open Office compress its files?
问题描述
我正在尝试以编程方式创建Open Office电子表格,但是由于某些原因,仅压缩包含所有必需文件的文件夹会使Open Office将文件标记为损坏.
I'm trying to create an Open Office spreadsheet programmatically but for some reason simply compressing a folder with all the necessary files makes Open Office flag the file as corrupted.
我是怎么做到的?我首先在Open Office中创建一个包含一些值的普通电子表格.保存后,将扩展名更改为.zip并制作该文件夹的副本.然后,我使用命令行zip压缩第二个文件夹,并将文件扩展名更改为.ods.尝试打开生成的文件时,我从Open Office收到一条错误消息,指出文件已损坏.
How did I get to this? I started by creating a normal spreadsheet in Open Office with some values in it. After saving I change the extension to .zip and make a copy of the folder. I then compress the second folder using command line zip and change the file extension to .ods. When trying to open the resulting file I get an error from Open Office saying the file is corrupt.
Open Office是否使用特殊的压缩算法?做一个文件test.ods"会把它显示为压缩的zip,那么Open Office在压缩程序中会添加些什么来使其正常工作?
Does Open Office use a special compression algorithm? Doing a "file test.ods" shows it as a compressed zip, so what does Open Office add during the compression routine to make it work?
推荐答案
Documentation here. This steps worked for me:
-
将原始文档文件(这是一个普通的zip文件)解压缩到某个目录:
Uncompress the original document file (it's a normal zip file) to some directory:
$ mkdir document
$ cd document
$ unzip ../document.odt
修改未压缩的数据.
Modify the uncompressed data.
创建一个新的odt:
$ zip -0 -X ../document2.odt mimetype
$ zip -r ../document2.odt * -x mimetype
这篇关于Open Office如何压缩其文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!