public class ExcelSaxUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static char |
CELL_FILL_CHAR
填充字符串
|
static int |
MAX_CELL_BIT
列的最大位数
|
| Constructor and Description |
|---|
ExcelSaxUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
countNullCell(String preRef,
String ref)
计算两个单元格之间的单元格数目(同一行)
|
static ExcelSaxReader<?> |
createSaxReader(boolean isXlsx,
RowHandler rowHandler)
|
static String |
formatCellContent(String value,
int numFmtIndex,
String numFmtString)
格式化数字或日期值
|
static Object |
getDataValue(CellDataType cellDataType,
String value,
org.apache.poi.xssf.model.SharedStrings sharedStrings,
String numFmtString)
根据数据类型获取数据
|
static DateTime |
getDateValue(double value)
获取日期
|
static DateTime |
getDateValue(String value)
获取日期
|
static Object |
getNumberOrDateValue(org.apache.poi.hssf.record.CellValueRecordInterface cell,
double value,
org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener formatListener)
在Excel03 sax读取中获取日期或数字类型的结果值
|
static boolean |
isDateFormat(org.apache.poi.hssf.record.CellValueRecordInterface cell,
org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener formatListener)
判断数字Record中是否为日期格式
|
static boolean |
isDateFormat(int formatIndex,
String formatString)
判断日期格式
|
static void |
readFrom(InputStream xmlDocStream,
ContentHandler handler)
从Excel的XML文档中读取内容,并使用
ContentHandler处理 |
public static final char CELL_FILL_CHAR
public static final int MAX_CELL_BIT
public static ExcelSaxReader<?> createSaxReader(boolean isXlsx, RowHandler rowHandler)
isXlsx - 是否为xlsx格式(07格式)rowHandler - 行处理器ExcelSaxReaderpublic static Object getDataValue(CellDataType cellDataType, String value, org.apache.poi.xssf.model.SharedStrings sharedStrings, String numFmtString)
cellDataType - 数据类型枚举value - 数据值sharedStrings - SharedStringsnumFmtString - 数字格式名public static String formatCellContent(String value, int numFmtIndex, String numFmtString)
value - 值numFmtIndex - 数字格式索引numFmtString - 数字格式名public static int countNullCell(String preRef, String ref)
preRef - 前一个单元格位置,例如A1ref - 当前单元格位置,例如A8public static void readFrom(InputStream xmlDocStream, ContentHandler handler) throws DependencyException, POIException, IORuntimeException
ContentHandler处理xmlDocStream - Excel的XML文档流handler - 文档内容处理接口,实现此接口用于回调处理数据DependencyException - 依赖异常POIException - POI异常,包装了SAXExceptionIORuntimeException - IO异常,如流关闭或异常等public static boolean isDateFormat(org.apache.poi.hssf.record.CellValueRecordInterface cell,
org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener formatListener)
cell - 单元格记录formatListener - FormatTrackingHSSFListenerpublic static boolean isDateFormat(int formatIndex,
String formatString)
formatIndex - 格式索引,一般用于内建格式formatString - 格式字符串ExcelDateUtil.isDateFormat(int, String)public static DateTime getDateValue(String value)
value - 单元格值public static DateTime getDateValue(double value)
value - 单元格值public static Object getNumberOrDateValue(org.apache.poi.hssf.record.CellValueRecordInterface cell, double value, org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener formatListener)
cell - 记录单元格value - 值formatListener - FormatTrackingHSSFListenerCopyright © 2025. All rights reserved.