|
|
|
@ -32,12 +32,16 @@ public class TestXml {
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws DocumentException {
|
|
|
|
|
String xml = "D:\\dsWork\\YunNanDsBase\\src\\main\\java\\com\\dsideal\\base\\Tools\\Test\\Sample.xml";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从XML中获取图表数据
|
|
|
|
|
* @param xmlPath
|
|
|
|
|
* @return
|
|
|
|
|
* @throws DocumentException
|
|
|
|
|
*/
|
|
|
|
|
public static List<List<String>> getChartData(String xmlPath) throws DocumentException {
|
|
|
|
|
// 创建 SAXReader 对象,读取 XML 文件
|
|
|
|
|
SAXReader reader = new SAXReader();
|
|
|
|
|
Document document = reader.read(new File(xml));
|
|
|
|
|
Document document = reader.read(new File(xmlPath));
|
|
|
|
|
// 获取根元素
|
|
|
|
|
Element root = document.getRootElement();
|
|
|
|
|
|
|
|
|
@ -123,6 +127,14 @@ public class TestXml {
|
|
|
|
|
// 将当前列添加到结果列表中
|
|
|
|
|
res.add(column);
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws DocumentException {
|
|
|
|
|
String xml = "D:\\dsWork\\YunNanDsBase\\src\\main\\java\\com\\dsideal\\base\\Tools\\Test\\Sample.xml";
|
|
|
|
|
|
|
|
|
|
List<List<String>> res = getChartData(xml);
|
|
|
|
|
//输出转置后的数据
|
|
|
|
|
ExcelKit.printTable(res);
|
|
|
|
|
}
|
|
|
|
|