public class XlsxReader extends DefaultHandler
| 限定符和类型 | 字段和说明 |
|---|---|
protected int |
curCol
当前列
|
protected int |
curRow
当前行
|
protected org.apache.commons.logging.Log |
log
日志
|
protected org.apache.poi.openxml4j.opc.OPCPackage |
pkg |
protected InputStream |
sheet |
| 构造器和说明 |
|---|
XlsxReader() |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
cellIsDate(long numFmtId)
单元格内容是否为时间
|
void |
characters(char[] ch,
int start,
int length) |
void |
endElement(String uri,
String localName,
String name) |
static int |
extractColumnNumber(String position) |
XMLReader |
fetchSheetParser(org.apache.poi.xssf.model.SharedStrings sst) |
void |
optRow(int sheetIndex,
int curRow,
List<String> rowList)
该方法自动被调用,每读一行调用一次,在方法中写自己的业务逻辑即可
|
static int |
parseColumnNumber(String columnIndicator)
Convert the column indicator in Excel like A, B, C, AE, CX and so on to a
1-based column number.
|
void |
process(String path)
读取所有工作簿的入口方法
|
void |
readOneSheet(String path)
读取第一个工作簿的入口方法
|
void |
startElement(String uri,
String localName,
String name,
Attributes attributes) |
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warningprotected org.apache.commons.logging.Log log
protected org.apache.poi.openxml4j.opc.OPCPackage pkg
protected InputStream sheet
protected int curRow
protected int curCol
public void readOneSheet(String path) throws Exception
path - 文件路径Exceptionpublic void process(String path) throws Exception
path - 文件路径Exception - 处理异常public void optRow(int sheetIndex,
int curRow,
List<String> rowList)
throws RuntimeException
sheetIndex - 工作簿序号curRow - 处理到第几行rowList - 当前数据行的数据集合RuntimeExceptionpublic XMLReader fetchSheetParser(org.apache.poi.xssf.model.SharedStrings sst) throws SAXException
SAXExceptionpublic void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException
startElement 在接口中 ContentHandlerstartElement 在类中 DefaultHandlerSAXExceptionpublic static int extractColumnNumber(String position)
public static int parseColumnNumber(String columnIndicator)
columnIndicator - The indicator to convertpublic void endElement(String uri, String localName, String name) throws SAXException
endElement 在接口中 ContentHandlerendElement 在类中 DefaultHandlerSAXExceptionpublic boolean cellIsDate(long numFmtId)
numFmtId - 单元格数字格式idpublic void characters(char[] ch,
int start,
int length)
throws SAXException
characters 在接口中 ContentHandlercharacters 在类中 DefaultHandlerSAXExceptionCopyright © 2024. All rights reserved.