如果使用stax解析将数据从xml文件提取到Excel,则单引号字符会自动添加到单元格数据的开头

时间:2018-11-20 09:53:46

标签: java parsing stax apostrophe hssfworkbook

SXSSFWorkbook wb = new SXSSFWorkbook(100);

StaxParserBaseExportHelperDetails staxParserBaseExportHelperDetails = new StaxParserBaseExportHelperDetails();
staxParserBaseExportHelperDetails.setUser(user);
staxParserBaseExportHelperDetails.setStyles(getXLSStyle());

try
{
    // First create a new XMLInputFactory
    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    // Setup a new streamReader
    staxParserBaseExportHelperDetails.setXmlStreamReader(inputFactory.createXMLStreamReader(in));

    while (staxParserBaseExportHelperDetails.getXmlStreamReader().hasNext())
    {
        staxParserBaseExportHelperDetails.setEventType(staxParserBaseExportHelperDetails.getXmlStreamReader().next());

        eventTypeStartElement(siteID, footerRequired, wb, staxParserBaseExportHelperDetails);
        eventTypeCharacters(staxParserBaseExportHelperDetails);
        eventTypeEndElement(wb, staxParserBaseExportHelperDetails, siteID, footerRequired);
    }
    wb.write(os);
    wb.dispose();
}
在下面的语句执行后添加了

撇号(') wb.write(os);

wb.write(os);

0 个答案:

没有答案