在没有 Apache POI 的情况下解析 Excel 文件 [英] Parsing Excel file without Apache POI

查看:33
本文介绍了在没有 Apache POI 的情况下解析 Excel 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我们可以使用 Apache POI 来解析 Excel 文件并获取数据.但是我听说一个奇怪的事情,excel 文件可以以我们解析 CSV 的类似方式传递(就像从文件 Stream 中读取文件并用逗号"分隔符分隔每个列值).当我们解析 Excel 时,我们必须使用制表符作为分隔符.是否可以?如果是,那么为什么 Apache 提出了如此复杂的框架.我很困惑.有人可以帮我吗?

I know that we can use Apache POI to parse an Excel file and get data. But I heard of a strange thing that excel file can be passed in a similar way we parse CSV (Like just read the file from file Stream and separate each column value with a "comma" separator). When we parse Excel we have to use tab as a delimiter. Is it possible? If yes then why Apache has come up with such a complicated framework. I am puzzled. Can someone help me?

推荐答案

CSV 是一种文本格式,因此可以使用分隔符进行解析.旧 Excel 是一种二进制和专有格式,因此需要巧妙的解码.新的 Excel 格式是压缩的 XML,但在将其转换为像逐个读取单元格这样简单的内容之前,还应该了解该文档的结构.因此,您的问题的答案是否定的,您需要使用 Apache POI,而且 - 这没有任何问题.

CSV is a text format, so it can be parsed using the delimiters. Old Excel is a binary and proprietary format so it needs clever decoding. The new Excel format is zipped XMLs, but one should also understand the structure of this document before it could be transformed into something as simple as reading cells one by one. So the answer to your question is no, you'll need to use Apache POI, and also - there's nothing wrong with that.

顺便说一句,在成为优秀开发人员的道路上,您需要在寻求帮助之前先学会做一些自己的研究.动手是最好的学习方式.

As a side note, on the path to become a good developer you will need to learn to do a bit of your own research before looking for help. Get your hands dirty is the best way to learn things.

这篇关于在没有 Apache POI 的情况下解析 Excel 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆