Search in sources :

Example 1 with XSSFExportToXml

use of org.apache.poi.xssf.extractor.XSSFExportToXml in project poi by apache.

the class CustomXMLMapping method main.

public static void main(String[] args) throws Exception {
    OPCPackage pkg = OPCPackage.open(args[0]);
    XSSFWorkbook wb = new XSSFWorkbook(pkg);
    for (XSSFMap map : wb.getCustomXMLMappings()) {
        XSSFExportToXml exporter = new XSSFExportToXml(map);
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        exporter.exportToXML(os, true);
        String xml = os.toString("UTF-8");
        System.out.println(xml);
    }
    pkg.close();
}
Also used : XSSFMap(org.apache.poi.xssf.usermodel.XSSFMap) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) XSSFExportToXml(org.apache.poi.xssf.extractor.XSSFExportToXml) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OPCPackage(org.apache.poi.openxml4j.opc.OPCPackage)

Example 2 with XSSFExportToXml

use of org.apache.poi.xssf.extractor.XSSFExportToXml in project poi by apache.

the class XSSFFileHandler method exportToXML.

private void exportToXML(XSSFWorkbook wb) throws SAXException, ParserConfigurationException, TransformerException {
    for (XSSFMap map : wb.getCustomXMLMappings()) {
        XSSFExportToXml exporter = new XSSFExportToXml(map);
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        exporter.exportToXML(os, true);
    }
}
Also used : XSSFMap(org.apache.poi.xssf.usermodel.XSSFMap) XSSFExportToXml(org.apache.poi.xssf.extractor.XSSFExportToXml) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 XSSFExportToXml (org.apache.poi.xssf.extractor.XSSFExportToXml)2 XSSFMap (org.apache.poi.xssf.usermodel.XSSFMap)2 OPCPackage (org.apache.poi.openxml4j.opc.OPCPackage)1 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)1