英文:
Parse Excel file using Go on OS X
问题
我正在尝试使用GoLang读取Excel文件(即使不是.xlsx格式),并使用几个库都无法成功。这些库在打开文件阶段会崩溃,并显示以下错误:
zip: not a valid zip file
我尝试使用的库有:
https://github.com/tealeg/xlsx
https://github.com/tealeg/xlsx2csv/
还有其他一些库,但它们在执行"go get Name-of-Lib"命令时由于某些DLL问题而崩溃。
有什么想法吗?这是因为我在MacOS下尝试还是其他原因?
英文:
I'm trying to read Excel file with GoLang (even not .xlsx) and by using several libraries can't have success in it. The libraries just crashes on OpenFile stage with such error:
zip: not a valid zip file
Libraries which I tried to use:
https://github.com/tealeg/xlsx
https://github.com/tealeg/xlsx2csv/
There were some others too, but they were crashed during
go get Name-of-Lib because of some Dll problems.
Any ideas? Is it because I'm trying to do in under MacOS or by some other reason?
答案1
得分: 4
你正在尝试使用的库1,2仅支持最新的Microsoft Excel格式,实际上是一个包含XML文档的zip文件。因此你会得到错误信息:zip: not a valid zip file
。这些库可以在你的MacOS上使用,但首先你需要将旧的XLS文件转换为XLSX文件。你可以像其他问题中描述的那样,使用LibreOffice的无界面模式来进行转换,你可以从你的代码中运行一个进程。
其他的库出现"dll"错误,是因为它们必须链接到Windows动态链接库。因此,它们在你的MacOS上无法使用。
英文:
The libraries you are trying to use 1, 2 support only newest Microsoft Excel format which is actually a zip with xml documents. Therefore you get error: zip: not a valid zip file
. Those can be used on your MacOS, but first you need to convert the old XLS files into XLSX files. You should be able to convert them with LibreOffice in headless mode like described other question, you can run a process from your code.
The other libraries are failing with "dll" errors because they must be linked against Windows Dynamic Link Libraries. As so, they are not usable on your MacOS.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论