在没有Apache POI的情况下解析Excel文件 [英] Parsing Excel file without Apache POI
问题描述
我知道我们可以使用Apache POI来解析Excel文件并获取数据。但我听说奇怪的是excel文件可以通过类似的方式传递我们解析CSV(就像从文件Stream中读取文件并用逗号分隔符分隔每个列值)。当我们解析Excel时,我们必须使用tab作为分隔符。可能吗?如果是,那么为什么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屋!