将xml文件转换为xls文件

将xml文件转换为xls文件

本文介绍了将xml文件转换为xls文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码编写了一个xml文件,如何将该文件转换为xls或csv文件?
我想读取一个xml文件并将其转换为xls文件,是否有可能实现这一点?

  //将内容写入xml文件
TransformerFactory transformerFactory = TransformerFactory.newInstance();
try {
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File(C:\\file.xml));
try {
//输出到控制台进行测试
// 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);
}
}
}


解决方案>

您可以使用在线网站进行转换。




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);
    }
}
}
解决方案

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

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

这篇关于将xml文件转换为xls文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 21:30