|
|
|
@ -369,7 +369,7 @@ public class ExcelKit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<List<String>> getChartData(String docPath, int chartNumber, int skipRowCount) throws IOException, InvalidFormatException, DocumentException, InterruptedException {
|
|
|
|
|
return getChartDataByXml(docPath, chartNumber, skipRowCount);
|
|
|
|
|
return getChartDataByXml(docPath, chartNumber, skipRowCount);
|
|
|
|
|
|
|
|
|
|
// InputStream is = new FileInputStream(docPath);
|
|
|
|
|
// ZipSecureFile.setMinInflateRatio(-1.0d);
|
|
|
|
@ -500,6 +500,7 @@ public class ExcelKit {
|
|
|
|
|
}
|
|
|
|
|
System.out.println();
|
|
|
|
|
}
|
|
|
|
|
System.out.println("====================================================");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -617,12 +618,28 @@ public class ExcelKit {
|
|
|
|
|
if (e == null) {
|
|
|
|
|
row.add(null);
|
|
|
|
|
} else {
|
|
|
|
|
row.add(e.element("v").getText());
|
|
|
|
|
//如果x可以转为小数,那么需要保留两位小数,如果可以转换为整数,那么直接返回整数,如果是字符串,就不变
|
|
|
|
|
String x = null;
|
|
|
|
|
try {
|
|
|
|
|
x = e.element("v").getText();
|
|
|
|
|
double d = Double.parseDouble(x);
|
|
|
|
|
if (d == (int) d) {
|
|
|
|
|
x = String.valueOf((int) d);
|
|
|
|
|
} else {
|
|
|
|
|
x = String.format("%.2f", d);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
//do nothing
|
|
|
|
|
}
|
|
|
|
|
row.add(x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
matrix.add(row);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printTable(matrix);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//上面生成的数据格式需要行转列,横坐标是年份,纵坐标是数据
|
|
|
|
|
int rowCount = matrix.size();// 计算行数和列数
|
|
|
|
|
int colCount = matrix.getFirst().size();
|
|
|
|
@ -636,17 +653,7 @@ public class ExcelKit {
|
|
|
|
|
// 遍历每一行,将当前列的值添加到新的内部列表中
|
|
|
|
|
for (int row = 0; row < rowCount; row++) {
|
|
|
|
|
String x = matrix.get(row).get(col);
|
|
|
|
|
//如果x可以转为小数,那么需要保留两位小数,如果可以转换为整数,那么直接返回整数,如果是字符串,就不变
|
|
|
|
|
try {
|
|
|
|
|
double d = Double.parseDouble(x);
|
|
|
|
|
if (d == (int) d) {
|
|
|
|
|
x = String.valueOf((int) d);
|
|
|
|
|
} else {
|
|
|
|
|
x = String.format("%.2f", d);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
//do nothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
column.add(x);
|
|
|
|
|
}
|
|
|
|
|
// 将当前列添加到结果列表中
|
|
|
|
|