Converting xml file into an xls file

一个人想着一个人 提交于 2020-01-06 14:04:21

问题


I wrote an xml file using the below codes, how to convert that file into xls or csv file? I want to read an xml file and covert it into an xls file, is there a possible way to do that?

            // write the content into xml file
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
        try {
            Transformer transformer = transformerFactory.newTransformer();
            DOMSource source = new DOMSource(doc);
            StreamResult result = new StreamResult(new File("C:\\file.xml"));
            try {
                // Output to console for testing
                // StreamResult result = new StreamResult(System.out);
                transformer.transform(source, result);

            } catch (TransformerException ex) {
                Logger.getLogger(CreditBureau.class.getName()).log(Level.SEVERE, null, ex);
            }
                 System.out.println("File saved!");

        } catch (TransformerConfigurationException ex) {
            Logger.getLogger(CreditBureau.class.getName()).log(Level.SEVERE, null, ex);
        }

    } catch (ParserConfigurationException ex) {
        Logger.getLogger(CreditBureau.class.getName()).log(Level.SEVERE, null, ex);
    }
}
}

回答1:


You can convert using online site .. http://www.luxonsoftware.com/converter/xmltoexcel

or http://xmlgrid.net/xmlToExcel.html




回答2:


You can look into Apache POI project. It's library which allow you to modify Microsoft documents.

http://poi.apache.org/



来源:https://stackoverflow.com/questions/20633650/converting-xml-file-into-an-xls-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!