XSSF POI是细胞日期 [英] XSSF POI is cell date

查看:823
本文介绍了XSSF POI是细胞日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,以确定是否细胞是约会吗?
我知道style.getDataFormatString(),但是这并不能帮助我,
因为我不能确定是否是格式化是日期或没有。

Is there a way to determine if cell is a date? I know about style.getDataFormatString() but that doesn't help me, because I can't determine if is formating is for date or not.

推荐答案

如果您使用的XSSF的usermodel,那么你想要的DateUtil.isCellDateFormatted(Cell) - 如果格式字符串小区重presents数据与否,这将返回一个布尔告诉你

If you're using the XSSF UserModel, then you want DateUtil.isCellDateFormatted(Cell) - this will return a boolean telling you if the format string for the cell represents a data or not.

如果你下来低电平XML的东西,你需要<一个href=\"http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DateUtil.html#isADateFormat%28int,%20java.lang.String%29\">DateUtil.isADateFormat(int,String)代替。风格ID来自细胞XML。风格字符串你必须走出的样式表,这是一个不同的包装部分。有装载帮手,虽然

If you're down at the low level XML stuff, you need DateUtil.isADateFormat(int,String) instead. The style ID comes from the cell xml. The style string you'll have to get out of the styles table, which is a different Package Part. There are helpers for loading that though

您可能想看看<一个href=\"http://svn.apache.org/repos/asf/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ooxml/XSSFExcelExtractorDecorator.java\">XSSFExcelExtractorDecorator从提卡中做了后者的一个例子 - 它的细胞格式从事件的解析

You probably want to look at XSSFExcelExtractorDecorator from Tika for an example of doing the latter - it does formatting of cells from an event parsing.

这篇关于XSSF POI是细胞日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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