|
|
|
@ -10,7 +10,6 @@ import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFFont;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFChart;
|
|
|
|
|
import org.dom4j.Document;
|
|
|
|
|
import org.dom4j.DocumentException;
|
|
|
|
|
import org.dom4j.Element;
|
|
|
|
@ -258,50 +257,6 @@ public class DsKit {
|
|
|
|
|
applyStyle(outRow, 0, stringList.size() - 1, dataStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 对图表List重新排序
|
|
|
|
|
*
|
|
|
|
|
* @param affCharts doc.getCharts()
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static List<XWPFChart> getSortListForXWPFChart(List<XWPFChart> affCharts) {
|
|
|
|
|
List<XWPFChart> charts = new ArrayList<>();
|
|
|
|
|
int itNumber = 0; //计数器
|
|
|
|
|
int oldNumber = 0; //入参计数器
|
|
|
|
|
while (itNumber < affCharts.size()) {
|
|
|
|
|
// 从oldCharts.get(0)开始检索,获取排序用图表名
|
|
|
|
|
String name = affCharts.get(oldNumber).getPackagePart().getPartName().toString();
|
|
|
|
|
// 获取此图表排序
|
|
|
|
|
String chartsNum = "";// 图表序号
|
|
|
|
|
boolean flag = false; // 上一个是否为数字
|
|
|
|
|
for (int i = 0; i < name.length(); i++) {
|
|
|
|
|
if (chartsNum.equals("") && name.charAt(i) >= 48 && name.charAt(i) <= 57) {
|
|
|
|
|
chartsNum += name.charAt(i);
|
|
|
|
|
flag = true;
|
|
|
|
|
} else if (flag && name.charAt(i) >= 48 && name.charAt(i) <= 57) {
|
|
|
|
|
chartsNum += name.charAt(i);
|
|
|
|
|
flag = true;
|
|
|
|
|
} else {
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//对比图表序号数字
|
|
|
|
|
int thisChartNum = Integer.parseInt(chartsNum);
|
|
|
|
|
if (thisChartNum == itNumber + 1) { //如果相等则加入返回list,且itNumber++
|
|
|
|
|
charts.add(affCharts.get(oldNumber));
|
|
|
|
|
itNumber++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//入参计数器+1 如果达到最大值则重置为0
|
|
|
|
|
if (oldNumber == affCharts.size() - 1) {
|
|
|
|
|
oldNumber = 0;
|
|
|
|
|
} else {
|
|
|
|
|
oldNumber++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return charts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存
|
|
|
|
|
*
|
|
|
|
@ -483,7 +438,7 @@ public class DsKit {
|
|
|
|
|
*
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
public static void unCompress(String wordPath) throws IOException {
|
|
|
|
|
public static int unCompress(String wordPath) throws IOException {
|
|
|
|
|
if (new File(DocxUnzipDirectory).exists()) {
|
|
|
|
|
FileUtils.deleteDirectory(new File(DocxUnzipDirectory));
|
|
|
|
|
}
|
|
|
|
@ -514,6 +469,19 @@ public class DsKit {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
inputStream.close();
|
|
|
|
|
|
|
|
|
|
String workingPath = DocxUnzipDirectory + "word\\charts\\";
|
|
|
|
|
//这个目录下的所有文件
|
|
|
|
|
File[] files = new File(workingPath).listFiles();
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
if (files != null) {
|
|
|
|
|
for (File f : files) {
|
|
|
|
|
if (f.getName().startsWith("chart") && f.getName().endsWith(".xml")) {
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return cnt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -592,7 +560,7 @@ public class DsKit {
|
|
|
|
|
Element ser = ce.elements("ser").get(i);
|
|
|
|
|
//cat 标签
|
|
|
|
|
Element cat = ser.element("cat");
|
|
|
|
|
if(cat==null) return tList;
|
|
|
|
|
if (cat == null) return tList;
|
|
|
|
|
Element numRef = cat.element("numRef");
|
|
|
|
|
if (numRef == null) numRef = cat.element("strRef");//这玩意有时是strRef,有时是numRef,Shit~
|
|
|
|
|
//数据
|
|
|
|
|