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

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

问题描述

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

解决方案

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

如果你想要 .xls 文件的 HSSF 事件处理的好例子,我建议你看看 来自 Apache POI 的 XLS2CSVmra来自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屋!

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