|
|
|
@ -1,19 +1,14 @@
|
|
|
|
|
package com.dsideal.base.Tools.FillData.City;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import com.dsideal.base.DataEase.Model.ExcelReader;
|
|
|
|
|
import com.dsideal.base.Tools.FillData.ExcelKit.ExcelKit;
|
|
|
|
|
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
|
|
|
|
|
import com.dsideal.base.Tools.Util.ReadDocxUtil;
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
|
|
import org.apache.poi.openxml4j.util.ZipSecureFile;
|
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
|
|
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.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -27,7 +22,7 @@ public class C1 {
|
|
|
|
|
//示例Excel
|
|
|
|
|
static String sampleExcelPath = "D:\\dsWork\\YunNanDsBase\\Doc\\待处理\\市\\【1】学前教育入园总量变化及预测\\学前教育入园总量变化及预测.xlsx";
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException, InvalidFormatException {
|
|
|
|
|
public static void main(String[] args) throws IOException, InvalidFormatException, InterruptedException {
|
|
|
|
|
//初始化数据库连接
|
|
|
|
|
LocalMysqlConnectUtil.Init();
|
|
|
|
|
//实例化
|
|
|
|
@ -64,19 +59,11 @@ public class C1 {
|
|
|
|
|
if (fileName.endsWith(".docx") && !fileName.startsWith("~")) {
|
|
|
|
|
System.out.println("正在处理" + cityName + "市州文件...");
|
|
|
|
|
//读取文件
|
|
|
|
|
String inputUrl = file.getAbsolutePath();
|
|
|
|
|
InputStream is = new FileInputStream(inputUrl);
|
|
|
|
|
ZipSecureFile.setMinInflateRatio(-1.0d);
|
|
|
|
|
XWPFDocument doc = new XWPFDocument(is);
|
|
|
|
|
//排序后的图表
|
|
|
|
|
List<XWPFChart> charts = ExcelKit.getSortListForXWPFChart(doc.getCharts());
|
|
|
|
|
|
|
|
|
|
//1号模板,数据在图表5和28中
|
|
|
|
|
int firstChartNumber = 5, secondChartNumber = 28;
|
|
|
|
|
XSSFWorkbook workbook = charts.get(firstChartNumber - 1).getWorkbook();
|
|
|
|
|
List<List<String>> source1 = ExcelKit.readSheet(workbook);
|
|
|
|
|
XSSFWorkbook workbook2 = charts.get(secondChartNumber - 1).getWorkbook();
|
|
|
|
|
List<List<String>> source2 = ExcelKit.readSheet(workbook2);
|
|
|
|
|
List<List<String>> source1 = ExcelKit.getChartData(file.getAbsolutePath(), firstChartNumber, 1, 10);
|
|
|
|
|
List<List<String>> source2 = ExcelKit.getChartData(file.getAbsolutePath(), secondChartNumber, 1, 10);
|
|
|
|
|
|
|
|
|
|
//遍历source1
|
|
|
|
|
for (List<String> r : source1) {
|
|
|
|
|