Package org.aoju.bus.office.excel
Class ExcelSaxKit
java.lang.Object
org.aoju.bus.office.excel.ExcelSaxKit
Sax方式读取Excel相关工具类
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcountNullCell(String preRef, String ref) 计算两个单元格之间的单元格数目(同一行)static ExcelSaxReader<?>createSaxReader(boolean isXlsx, RowHandler rowHandler) static StringformatCellContent(String value, int numFmtIndex, String numFmtString) 格式化数字或日期值static ObjectgetDataValue(CellDataType cellDataType, String value, org.apache.poi.xssf.model.SharedStrings sharedStrings, String numFmtString) 根据数据类型获取数据static org.aoju.bus.core.date.DateTimegetDateValue(double value) 获取日期static org.aoju.bus.core.date.DateTimegetDateValue(String value) 获取日期static ObjectgetNumberOrDateValue(org.apache.poi.hssf.record.CellValueRecordInterface cell, double value, org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener formatListener) 在Excel03 sax读取中获取日期或数字类型的结果值static booleanisDateFormat(int formatIndex, String formatString) 判断日期格式static booleanisDateFormat(org.apache.poi.ss.usermodel.Cell cell) static booleanisDateFormat(org.apache.poi.ss.usermodel.Cell cell, org.apache.poi.ss.formula.ConditionalFormattingEvaluator cfEvaluator) 判断是否日期格式static booleanisDateFormat(org.apache.poi.ss.usermodel.ExcelNumberFormat numFmt) 判断是否日期格式static voidreadFrom(InputStream xmlDocStream, ContentHandler handler) 从Excel的XML文档中读取内容,并使用ContentHandler处理
-
Field Details
-
CELL_FILL_CHAR
public static final char CELL_FILL_CHAR- See Also:
-
MAX_CELL_BIT
public static final int MAX_CELL_BIT- See Also:
-
-
Constructor Details
-
ExcelSaxKit
public ExcelSaxKit()
-
-
Method Details
-
createSaxReader
- Parameters:
isXlsx- 是否为xlsx格式(07格式)rowHandler- 行处理器- Returns:
ExcelSaxReader
-
formatCellContent
格式化数字或日期值- Parameters:
value- 值numFmtIndex- 数字格式索引numFmtString- 数字格式名- Returns:
- 格式化后的值
-
countNullCell
计算两个单元格之间的单元格数目(同一行)- Parameters:
preRef- 前一个单元格位置,例如A1ref- 当前单元格位置,例如A8- Returns:
- 同一行中两个单元格之间的空单元格数
-
readFrom
public static void readFrom(InputStream xmlDocStream, ContentHandler handler) throws org.aoju.bus.core.exception.InternalException 从Excel的XML文档中读取内容,并使用ContentHandler处理- Parameters:
xmlDocStream- Excel的XML文档流handler- 文档内容处理接口,实现此接口用于回调处理数据- Throws:
org.aoju.bus.core.exception.InternalException- POI异常,包装了SAXException
-
getDateValue
获取日期- Parameters:
value- 单元格值- Returns:
- 日期
-
getDateValue
public static org.aoju.bus.core.date.DateTime getDateValue(double value) 获取日期- Parameters:
value- 单元格值- Returns:
- 日期
-
getNumberOrDateValue
public static Object getNumberOrDateValue(org.apache.poi.hssf.record.CellValueRecordInterface cell, double value, org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener formatListener) 在Excel03 sax读取中获取日期或数字类型的结果值- Parameters:
cell- 记录单元格value- 值formatListener-FormatTrackingHSSFListener- Returns:
- 值,可能为Date或Double或Long
-
isDateFormat
public static boolean isDateFormat(org.apache.poi.ss.usermodel.Cell cell) -
isDateFormat
public static boolean isDateFormat(org.apache.poi.ss.usermodel.Cell cell, org.apache.poi.ss.formula.ConditionalFormattingEvaluator cfEvaluator) 判断是否日期格式- Parameters:
cell- 单元格cfEvaluator-ConditionalFormattingEvaluator- Returns:
- 是否日期格式
-
isDateFormat
public static boolean isDateFormat(org.apache.poi.ss.usermodel.ExcelNumberFormat numFmt) 判断是否日期格式- Parameters:
numFmt-ExcelNumberFormat- Returns:
- 是否日期格式
-
isDateFormat
判断日期格式- Parameters:
formatIndex- 格式索引,一般用于内建格式formatString- 格式字符串- Returns:
- 是否为日期格式
-