使用Apache POI HSSFListener如何识别日期类型 [英] Using Apache POI HSSFListener how to identify date type

查看:232
本文介绍了使用Apache POI HSSFListener如何识别日期类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于要处理数百万条记录,因此我必须使用此处提供的技术来处理SAX解析. http://poi.apache.org/spreadsheet/how-to.html#event_api .但是,日期类型已转换为数字.使用HSSFListener时如何区分日期和数字?

解决方案

Excel文件格式将所有日期存储为带有特殊格式设置规则的数字.不是HSSF在转换它,而是您得到的正是Excel存储在文件中的内容!

如果您想要.xls文件的HSSF事件处理的好示例,我建议您看一下

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屋!

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