|
|
|
@ -1,49 +0,0 @@
|
|
|
|
|
package com.dsideal.base.Tools;
|
|
|
|
|
|
|
|
|
|
import com.dsideal.base.Tools.FillData.DataEaseKit.DsKit;
|
|
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
|
|
import org.apache.poi.openxml4j.util.ZipSecureFile;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFChart;
|
|
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class CheckWordChart {
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException, InvalidFormatException, InterruptedException {
|
|
|
|
|
String path = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\16个州市报告2022\\分析报告20240510";
|
|
|
|
|
//获取此目录下所有的文件,需要以docx结尾,并且,不能以~开头
|
|
|
|
|
File file = new File(path);
|
|
|
|
|
File[] files = file.listFiles();
|
|
|
|
|
for (File f : files) {
|
|
|
|
|
if (f.getName().endsWith(".docx") && !f.getName().startsWith("~")) {
|
|
|
|
|
String sourceWord = f.getAbsolutePath();
|
|
|
|
|
InputStream is = new FileInputStream(sourceWord);
|
|
|
|
|
ZipSecureFile.setMinInflateRatio(-1.0d);
|
|
|
|
|
XWPFDocument doc = new XWPFDocument(is);
|
|
|
|
|
//直接输出图表数量
|
|
|
|
|
//System.out.println("doc.getCharts=" + doc.getCharts().size());
|
|
|
|
|
List<XWPFChart> chartList = doc.getCharts();
|
|
|
|
|
//排序后的图表
|
|
|
|
|
chartList = DsKit.getSortListForXWPFChart(chartList);
|
|
|
|
|
//遍历输出
|
|
|
|
|
for (int i = 0; i < chartList.size(); i++) {
|
|
|
|
|
XWPFChart chart = chartList.get(i);
|
|
|
|
|
XSSFWorkbook workbook = chart.getWorkbook();
|
|
|
|
|
XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
|
if (sheet.getPhysicalNumberOfRows() == 0) {
|
|
|
|
|
System.out.println(sourceWord + ",第" + (i + 1) + "个图表需要人工编辑一下Sheet名称,否则无法读取!===");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//关闭流
|
|
|
|
|
is.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|