使用Apache POI HSSFListener如何识别日期类型 [英] Using Apache POI HSSFListener how to identify date type
问题描述
由于要处理数百万条记录,因此我必须使用此处提供的技术来处理SAX解析. http://poi.apache.org/spreadsheet/how-to.html#event_api .但是,日期类型已转换为数字.使用HSSFListener时如何区分日期和数字?
Excel文件格式将所有日期存储为带有特殊格式设置规则的数字.不是HSSF在转换它,而是您得到的正是Excel存储在文件中的内容!
如果您想要.xls文件的HSSF事件处理的好示例,我建议您看一下来自Apache Tika的ExcelExtractor >
两者都显示了许多您想做的常见事情,包括检测日期"单元格并对其进行适当格式化以进行显示
Due to millions of records to handle, I have to handle SAX parsing using the technique given here. http://poi.apache.org/spreadsheet/how-to.html#event_api. However Date type is convered to Number. How to distinguish between Date and Number when using HSSFListener?
The Excel file formats store all dates as numbers with special formatting rules. It's not that HSSF is converting it, you're getting exactly what Excel stores in the file!
If you want good examples of HSSF Event processing for .xls files, I would suggest you take a look at XLS2CSVmra from Apache POI and ExcelExtractor from Apache Tika
Both show a number of common things you'll want to do, including detecting Date cells and formatting them appropriately for display
这篇关于使用Apache POI HSSFListener如何识别日期类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!