E2xCmdline.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:Excel2XML 作者:
/**
 * Parses an inputstream containin xlsx into an outputStream containing XML
 * 
 * @param inputStream
 *            the source
 * @param outputStream
 *            the result
 * @throws IOException
 * @throws XMLStreamException
 */
public void parse(final InputStream inputStream, final OutputStream outputStream)
        throws IOException, XMLStreamException {
    XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
    XMLStreamWriter out = this.getXMLWriter(outputStream);
    out.writeStartDocument();
    out.writeStartElement("workbook");
    int sheetCount = workbook.getNumberOfSheets();
    for (int i = 0; i < sheetCount; i++) {
        final XSSFSheet sheet = workbook.getSheetAt(i);
        try {
            this.export(sheet, out);
        } catch (UnsupportedEncodingException | FileNotFoundException | XMLStreamException
                | FactoryConfigurationError e) {
            e.printStackTrace();
        }
    }
    out.writeEndElement();
    out.writeEndDocument();
    out.close();
    workbook.close();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号