【问题】
What is the best way to read excel spreadsheet?
I need to programmtically read excel spreadsheet and then insert the data into a database. Although I am more inclined towards Perl or Java, I want to know the best and fastest possible way. Language and technology no bar. Also, if it's open source, then better.
别人的回答:
Have you looked at jq? It's a utility, but it's open source and has its own parsing syntax akin to XPath. You could probably also port it.
Similarly, almost every language out there has a very current and powerful library for parsing JSON. Python has simplejson, Ruby has, uh, the "json" gem, Java has Jackson JSON Processor - Home, the list goes on.
【回答】
Perl访问excel需要先执行cpan Spreadsheet::ParseExcel命令安装相关的类包,然后调用其接口访问。Java可以利用POI访问excel,但是在数据类型处理和数据计算(条件过滤、分组、连接等)方面都比较复杂。推荐使用集算器,读取excel只需要一行代码:=file("D:\\data.xls").xlsimport(),而且可以在IDE中浏览导入的数据。集算器支持jdbc,可以方便的将excel数据写入数据库,参考【SPL 实现 txt 和 Excel 数据入库】。虽然集算器不是开源的,但是有免费版本。