kgdxpr 9 months ago
commit de3e40fa59

@ -15,6 +15,8 @@ import org.apache.poi.xwpf.usermodel.XWPFChart;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class C1 {
@ -27,8 +29,12 @@ public class C1 {
//实例化
ReadDocxUtil ru = new ReadDocxUtil();
//开始读取市州word文档
String parentPath = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\16个州市报告2022\\分析报告20240510";
//示例Excel
String sampleExcelPath = "D:\\dsWork\\YunNanDsBase\\Doc\\待处理\\市\\【1】学前教育入园总量变化及预测\\学前教育入园总量变化及预测.xlsx";
//目标Excel,就是把文件名解析出来后,后面添加上【成果】,需要动态计算获取,不能写死
String excelPath = sampleExcelPath.replace(".xlsx", "【成果】.xlsx");
ExcelKit.delExcel(excelPath);
@ -36,29 +42,17 @@ public class C1 {
//目标Excel
XSSFWorkbook outWorkbook = new XSSFWorkbook();
//目标Sheet
XSSFSheet outSheet = outWorkbook.createSheet("Sheet1");
XSSFSheet outSheet = ExcelKit.CreateSheet(outWorkbook);
//应用样式
XSSFCellStyle headerStyle = ExcelKit.getHeaderStyle(outWorkbook);
XSSFCellStyle dataStyle = ExcelKit.getDataStyle(outWorkbook);
//先把样例的第一行复制到目标输出Excel的第一行中去
Row firstRow = outSheet.createRow(0);
//样例Excel
XSSFWorkbook sampleWorkbook = new XSSFWorkbook(sampleExcelPath);
//样例Sheet
XSSFSheet sampleSheet = sampleWorkbook.getSheet("Sheet1");
Row firstSampleRow = sampleSheet.getRow(0);
for (Cell cell : firstSampleRow) {
Cell outCell = firstRow.createCell(cell.getColumnIndex());
outCell.setCellValue(ExcelReader.readCell(cell));
outCell.setCellStyle(headerStyle); // 应用加粗样式
}
sampleWorkbook.close();
//开始读取市州word文档
String parentPath = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\16个州市报告2022\\分析报告20240510";
//拷贝文件头
ExcelKit.CopyHead(sampleExcelPath, outSheet, headerStyle);
//找到parentPath下一级目录中所有文件
File[] files = new File(parentPath).listFiles();
int rowIndex = 0;
//处理这个目录
if (files != null) {
for (File file : files) {
@ -76,158 +70,102 @@ public class C1 {
ZipSecureFile.setMinInflateRatio(-1.0d);
XWPFDocument doc = new XWPFDocument(is);
//图表
List<XWPFChart> charts = doc.getCharts();
//排序后的图表
List<XWPFChart> charts = ExcelKit.getSortListForXWPFChart(doc.getCharts());
//1号模板数据在图表5和28中
XWPFChart chart5 = charts.get(4);
XSSFWorkbook workbook = chart5.getWorkbook();
XSSFSheet sheet = workbook.getSheet("Sheet1");
//遍历输出sheet的内容
int rowIndex = 0;
Row outRow;
for (Row row : sheet) {
rowIndex++;
if (rowIndex == 1) continue;
//年份
int columnIndex = 0;
String value = ExcelReader.readCell(row.getCell(columnIndex));
outRow = outSheet.createRow(rowIndex - 1);
outRow.createCell(columnIndex).setCellValue(value);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//总量分类
columnIndex = 1;
outRow.createCell(columnIndex).setCellValue("总入园数");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//区域分类
columnIndex = 2;
outRow.createCell(columnIndex).setCellValue("");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//总量数值
columnIndex = 3;
value = ExcelReader.readCell(row.getCell(4));
outRow.createCell(columnIndex).setCellValue(value);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//区域数值
columnIndex = 4;
outRow.createCell(columnIndex).setCellValue("");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//行政区划
columnIndex = 5;
outRow.createCell(columnIndex).setCellValue(cityName);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//上级行政区划
columnIndex = 6;
outRow.createCell(columnIndex).setCellValue("云南省");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
XSSFWorkbook workbook = charts.get(4).getWorkbook();
List<List<String>> source1 = ExcelKit.readSheet(workbook);
XSSFWorkbook workbook2 = charts.get(27).getWorkbook();
List<List<String>> source2 = ExcelKit.readSheet(workbook2);
//遍历source1
for (int i = 0; i < source1.size(); i++) {
List<String> r = source1.get(i);
Row outRow = outSheet.createRow(++rowIndex);
// 需要写死列的对应关系
ExcelKit.putData(outRow, new ArrayList<>(Arrays.asList(r.getFirst(), "总入园数", "", r.get(4), "", cityName, "云南省")), dataStyle);
//年份,总量分类,区域分类,总量数值,区域数值,行政区划,上级行政区划
}
workbook.close();
//==============================================================================
//读取第28个图表
XWPFChart chart28 = charts.get(27);
workbook = chart28.getWorkbook();
sheet = workbook.getSheet("Sheet1");
String jiShu = "";
//遍历输出sheet的内容
int secondRowIndex = 0;
for (Row row : sheet) {
secondRowIndex++;
if (secondRowIndex == 1) continue;//表头都跳过
if (secondRowIndex == 2) {//2022年是重复的取一回就行了
jiShu = ExcelReader.readCell(row.getCell(4));//2022年基数
}
rowIndex++;
//年份
int columnIndex = 0;
if (row.getCell(columnIndex) == null) break;
String value = ExcelReader.readCell(row.getCell(columnIndex));
outRow = outSheet.createRow(rowIndex - 1);
outRow.createCell(columnIndex).setCellValue(value);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//总量分类
columnIndex = 1;
outRow.createCell(columnIndex).setCellValue("总入园数");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//区域分类
columnIndex = 2;
outRow.createCell(columnIndex).setCellValue("");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//总量数值
columnIndex = 3;
value = ExcelReader.readCell(row.getCell(4));
outRow.createCell(columnIndex).setCellValue(value);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//区域数值
columnIndex = 4;
outRow.createCell(columnIndex).setCellValue("");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//行政区划
columnIndex = 5;
outRow.createCell(columnIndex).setCellValue(cityName);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//上级行政区划
columnIndex = 6;
outRow.createCell(columnIndex).setCellValue("云南省");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//遍历source2
for (int i = 0; i < source2.size(); i++) {
if (i == 0) continue;//跳过2022年这个年份重复了
List<String> r = source2.get(i);
Row outRow = outSheet.createRow(++rowIndex);
// 需要写死列的对应关系
outRow.createCell(0).setCellValue(r.getFirst());//年份
outRow.createCell(1).setCellValue("总入园数");//总量分类
outRow.createCell(2).setCellValue("");//区域分类
outRow.createCell(3).setCellValue(r.get(4));//总量数值
outRow.createCell(4).setCellValue("");//区域数值
outRow.createCell(5).setCellValue(cityName);//行政区划
outRow.createCell(6).setCellValue("云南省");//上级行政区划
//应用一下样式
ExcelKit.applyStyle(outRow, 0, 6, dataStyle);
}
//重复读取,跳过表头
rowIndex--;
for (Row row : sheet) {
//年份
int columnIndex = 0;
if (row.getCell(columnIndex) == null) break;
String value = ExcelReader.readCell(row.getCell(columnIndex));
if (StrKit.isBlank(value)) continue;
rowIndex++;
outRow = outSheet.createRow(rowIndex - 1);
outRow.createCell(columnIndex).setCellValue(value);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//总量分类
columnIndex = 1;
outRow.createCell(columnIndex).setCellValue("2022年基数");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//区域分类
columnIndex = 2;
outRow.createCell(columnIndex).setCellValue("");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//总量数值
columnIndex = 3;
value = ExcelReader.readCell(row.getCell(4));
outRow.createCell(columnIndex).setCellValue(jiShu);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//区域数值
columnIndex = 4;
outRow.createCell(columnIndex).setCellValue("");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//行政区划
columnIndex = 5;
outRow.createCell(columnIndex).setCellValue(cityName);
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//上级行政区划
columnIndex = 6;
outRow.createCell(columnIndex).setCellValue("云南省");
outRow.getCell(columnIndex).setCellStyle(dataStyle);
//2022年基数:遍历source2
for (int i = 0; i < source2.size(); i++) {
List<String> r = source2.get(i);
Row outRow = outSheet.createRow(++rowIndex);
// 需要写死列的对应关系
outRow.createCell(0).setCellValue(r.getFirst());//年份
outRow.createCell(1).setCellValue("2022年基数");//基数
outRow.createCell(2).setCellValue("");//区域分类
outRow.createCell(3).setCellValue(source2.getFirst().get(4));//总量数值
outRow.createCell(4).setCellValue("");//区域数值
outRow.createCell(5).setCellValue(cityName);//行政区划
outRow.createCell(6).setCellValue("云南省");//上级行政区划
//应用一下样式
ExcelKit.applyStyle(outRow, 0, 6, dataStyle);
}
//城区+镇区+乡村
List<String> areaList = new ArrayList<>();
areaList.add("城区");
areaList.add("镇区");
areaList.add("乡村");
for (int k = 0; k < areaList.size(); k++) {
String areaName = areaList.get(k);
for (int i = 0; i < source1.size(); i++) {
List<String> r = source1.get(i);
Row outRow = outSheet.createRow(++rowIndex);
// 需要写死列的对应关系
outRow.createCell(0).setCellValue(r.getFirst());//年份
outRow.createCell(1).setCellValue("");//总量分类
outRow.createCell(2).setCellValue(areaName);//区域分类
outRow.createCell(3).setCellValue("");//总量数值
outRow.createCell(4).setCellValue(r.get(k + 1));//区域数值
outRow.createCell(5).setCellValue(cityName);//行政区划
outRow.createCell(6).setCellValue("云南省");//上级行政区划
//应用一下样式
ExcelKit.applyStyle(outRow, 0, 6, dataStyle);
}
for (int i = 0; i < source2.size(); i++) {
if (i == 0) continue;
List<String> r = source2.get(i);
Row outRow = outSheet.createRow(++rowIndex);
// 需要写死列的对应关系
outRow.createCell(0).setCellValue(r.getFirst());//年份
outRow.createCell(1).setCellValue("");//基数
outRow.createCell(2).setCellValue(areaName);//区域分类
outRow.createCell(3).setCellValue("");//总量数值
outRow.createCell(4).setCellValue(r.get(k + 1));//区域数值
outRow.createCell(5).setCellValue(cityName);//行政区划
outRow.createCell(6).setCellValue("云南省");//上级行政区划
//应用一下样式
ExcelKit.applyStyle(outRow, 0, 6, dataStyle);
}
}
workbook.close();
//城区
//镇区
//乡村
break;
}
System.out.println("正在处理" + cityName + "市州文件...");
}
}
//保存Excel
outSheet.setDefaultColumnWidth(20);
outSheet.setDefaultRowHeight((short) 500);
FileOutputStream fileOut = new FileOutputStream(excelPath);
outWorkbook.write(fileOut);
outWorkbook.close();

@ -1,13 +1,18 @@
package com.dsideal.base.Tools.FillData.ExcelKit;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import com.dsideal.base.DataEase.Model.ExcelReader;
import com.jfinal.kit.StrKit;
import org.apache.poi.ss.usermodel.*;
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 java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class ExcelKit {
/**
@ -34,6 +39,7 @@ public class ExcelKit {
/**
*
*
* @param workbook 簿
* @return
*/
@ -51,13 +57,208 @@ public class ExcelKit {
/**
* Excel
*
* @param excelPath
*/
public static void delExcel(String excelPath){
public static void delExcel(String excelPath) {
//如果目录文件存在,则删除
File fi = new File(excelPath);
if (fi.exists()) {
fi.delete();
}
}
/**
* Excel
*
* @param sampleExcelPath
* @param outSheet
* @param headerStyle
* @throws IOException
*/
public static void CopyHead(String sampleExcelPath, XSSFSheet outSheet, XSSFCellStyle headerStyle) throws IOException {
//样例Excel
XSSFWorkbook sampleWorkbook = new XSSFWorkbook(sampleExcelPath);
//先把样例的第一行复制到目标输出Excel的第一行中去
Row firstRow = outSheet.createRow(0);
//样例Sheet
XSSFSheet sampleSheet = sampleWorkbook.getSheet("Sheet1");
Row firstSampleRow = sampleSheet.getRow(0);
for (Cell cell : firstSampleRow) {
Cell outCell = firstRow.createCell(cell.getColumnIndex());
outCell.setCellValue(ExcelReader.readCell(cell));
outCell.setCellStyle(headerStyle); // 应用加粗样式
}
sampleWorkbook.close();
}
/**
* Sheet
*
* @param outWorkbook
* @return
*/
public static XSSFSheet CreateSheet(XSSFWorkbook outWorkbook) {
XSSFSheet outSheet = outWorkbook.createSheet("Sheet1");
//保存Excel
outSheet.setDefaultColumnWidth(20);
outSheet.setDefaultRowHeight((short) 500);
return outSheet;
}
/**
* @param workbook
* @return
* @throws IOException
*/
public static List<List<String>> readSheet(XSSFWorkbook workbook) throws IOException {
XSSFSheet sheet = workbook.getSheet("Sheet1");
List<List<String>> array = new ArrayList<>();
//遍历输出sheet的内容
int rowIndex = 0;
// 遍历工作表中的所有行
if (sheet == null) return array;
for (Row row : sheet) {
rowIndex++;
if (rowIndex == 1) continue;//第一行为表头
if (row == null) break;
if (row.getCell(0) == null) break;
if (StrKit.isBlank(readCell(row.getCell(0)))) {
break;
}
// 遍历行中的所有单元格
List<String> X = new ArrayList<>();
for (Cell cell : row) {
X.add(ExcelReader.readCell(cell));
}
array.add(X);
}
workbook.close();
return array;
}
/**
*
*
* @param cell
*/
public static String readCell(Cell cell) {
// 根据单元格的类型来读取值
switch (cell.getCellType()) {
case STRING:
// 字符串类型的单元格
return cell.getStringCellValue();
case NUMERIC:
// 数字类型的单元格
if (DateUtil.isCellDateFormatted(cell)) {
// 如果是日期类型的单元格
return cell.getDateCellValue().toString();
} else {
// 判断是否为整数
double value = cell.getNumericCellValue();
if (value == (int) value) {
// 整数
return String.valueOf((int) value);
} else {
// 小数,保留两位小数
value = cell.getNumericCellValue();
return String.format("%.2f", value);
}
}
case FORMULA:
// 公式类型的单元格
cell.setCellType(CellType.NUMERIC); // 将公式计算结果转为数字
if (DateUtil.isCellDateFormatted(cell)) {
// 如果是日期类型的单元格
return cell.getDateCellValue().toString();
} else {
double formulaValue = cell.getNumericCellValue();
if (formulaValue == (int) formulaValue) {
// 整数
return String.valueOf((int) formulaValue);
} else {
// 小数,保留两位小数
double value = cell.getNumericCellValue();
return String.format("%.2f", value);
}
}
// 可以添加其他类型的处理,如 BOOLEAN, ERROR 等
default:
// 其他类型的单元格
return cell.toString();
}
}
/**
*
*
* @param outRow
* @param start
* @param end
* @param dataStyle
*/
public static void applyStyle(Row outRow, int start, int end, XSSFCellStyle dataStyle) {
for (int i = start; i <= end; i++) {
outRow.getCell(i).setCellStyle(dataStyle);
}
}
/**
*
*
* @param outRow
* @param stringList
*/
public static void putData(Row outRow, List<String> stringList, XSSFCellStyle dataStyle) {
for (int i = 0; i < stringList.size(); i++) {
outRow.createCell(i).setCellValue(stringList.get(i));
}
//应用一下样式
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;
}
}

@ -34,40 +34,43 @@ public class Step4_ReaderWord {
if (!extension.equals("docx")) continue;
//城市名称
String cityName = ru.getCityOrAreaName(file.getName());
ru.doOne(file, cityName, excelDir);
if(cityName!=null && cityName.equals("迪庆藏族自治州")){
ru.doOne(file, cityName, excelDir);
}
}
}
System.out.println("市州所有文件处理完成!");
//开始处理区县word文档
String directoryPath = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\133个县区报告2022\\县区研究报告";
// 调用 Hutool 的 FileUtil.loopFiles 方法递归获取所有文件
List<File> areaFiles = FileUtil.loopFiles(directoryPath, file -> {
// 这里可以添加你的过滤条件,如果不需要过滤,返回 true 即可
return true;
});
//处理这个目录
if (files != null) {
for (File file : areaFiles) {
//判断file是不是目录是目录的需要跳过
if (file.isDirectory()) continue;
//城市名称
String areaName = ru.getCityOrAreaName(file.getName());
String root = "D:\\dsWork\\YunNanDsBase\\Doc\\Excel\\县区";
excelDir = new File(root);
//如果不存在则创建
if (!excelDir.exists()) excelDir.mkdirs();
if (!StrKit.isBlank(areaName)) {
//获取此文件的所属市州
//D:\dsWork\YunNanDsBase\Doc\全省及州市县区人口与教育报告集20241023\133个县区报告2022\县区研究报告\保山市各县区报告5
String[] c = file.getAbsolutePath().split("\\\\");
String cityName = ru.getCityOrAreaName(c[7]);
excelDir = new File(root + "\\" + cityName);
if (!excelDir.exists()) excelDir.mkdirs();
ru.doOne(file, areaName, excelDir);
}
}
}
System.out.println("县区所有文件处理完成!");
// //开始处理区县word文档
// String directoryPath = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\133个县区报告2022\\县区研究报告";
// // 调用 Hutool 的 FileUtil.loopFiles 方法递归获取所有文件
// List<File> areaFiles = FileUtil.loopFiles(directoryPath, file -> {
// // 这里可以添加你的过滤条件,如果不需要过滤,返回 true 即可
// return true;
// });
// //处理这个目录
// if (files != null) {
// for (File file : areaFiles) {
// //判断file是不是目录是目录的需要跳过
// if (file.isDirectory()) continue;
// //城市名称
// String areaName = ru.getCityOrAreaName(file.getName());
// String root = "D:\\dsWork\\YunNanDsBase\\Doc\\Excel\\县区";
// excelDir = new File(root);
// //如果不存在则创建
// if (!excelDir.exists()) excelDir.mkdirs();
// if (!StrKit.isBlank(areaName)) {
// //获取此文件的所属市州
// //D:\dsWork\YunNanDsBase\Doc\全省及州市县区人口与教育报告集20241023\133个县区报告2022\县区研究报告\保山市各县区报告5
// String[] c = file.getAbsolutePath().split("\\\\");
// String cityName = ru.getCityOrAreaName(c[7]);
// excelDir = new File(root + "\\" + cityName);
// if (!excelDir.exists()) excelDir.mkdirs();
// ru.doOne(file, areaName, excelDir);
// }
// }
// }
// System.out.println("县区所有文件处理完成!");
}
}

@ -1,5 +1,6 @@
package com.dsideal.base.Tools;
import com.dsideal.base.Tools.FillData.ExcelKit.ExcelKit;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -8,55 +9,7 @@ import java.io.IOException;
public class Step5_ReaderExcel {
public static void readCell(Cell cell){
// 根据单元格的类型来读取值
switch (cell.getCellType()) {
case STRING:
// 字符串类型的单元格
String stringValue = cell.getStringCellValue();
System.out.print(stringValue + "\t");
break;
case NUMERIC:
// 数字类型的单元格
if (DateUtil.isCellDateFormatted(cell)) {
// 如果是日期类型的单元格
System.out.print(cell.getDateCellValue() + "\t");
} else {
// 判断是否为整数
double value = cell.getNumericCellValue();
if (value == (int) value) {
// 整数
System.out.print((int) value + "\t");
} else {
// 小数,保留两位小数
System.out.printf("%.2f\t", cell.getNumericCellValue());
}
}
break;
case FORMULA:
// 公式类型的单元格
cell.setCellType(CellType.NUMERIC); // 将公式计算结果转为数字
if (DateUtil.isCellDateFormatted(cell)) {
// 如果是日期类型的单元格
System.out.print(cell.getDateCellValue() + "\t");
} else {
double formulaValue = cell.getNumericCellValue();
if (formulaValue == (int) formulaValue) {
// 整数
System.out.print((int) formulaValue + "\t");
} else {
// 小数,保留两位小数
System.out.printf("%.2f\t", cell.getNumericCellValue());
}
}
break;
// 可以添加其他类型的处理,如 BOOLEAN, ERROR 等
default:
// 其他类型的单元格
System.out.print(cell + "\t");
break;
}
}
public static void main(String[] args) throws IOException {
String filePath = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\133个县区报告2022\\县区研究报告\\楚雄州各县市报告10\\1.楚雄市人口变化趋势对基础教育的影响分析报告\\附件2 楚雄市教育发展规模数据收集表2024.06.13.xlsx";
//第一个表格的宽度=23
@ -80,7 +33,7 @@ public class Step5_ReaderExcel {
// 读取表格数据
for (int j = 0; j < firstTableWidth; j++) {
Cell cell = row.getCell(j);
readCell(cell);
ExcelKit.readCell(cell);
}
System.out.println();
}
@ -117,7 +70,7 @@ public class Step5_ReaderExcel {
// 计算公式结果
cell.setCellType(CellType.NUMERIC);
}
readCell(cell);
ExcelKit.readCell(cell);
}
System.out.println();
}

@ -121,6 +121,9 @@ public class ReadDocxUtil {
List<XWPFChart> charts = doc.getCharts();
//System.out.println("图表数量=" + charts.size() + ",图例个数=" + num);
for (int i = 0; i < charts.size(); i++) {
if(i==4){
System.out.println("Here!");
}
XWPFChart chart = charts.get(i);
XSSFWorkbook workbook = chart.getWorkbook();
// 创建FileOutputStream对象用于写入新的Excel文件

Loading…
Cancel
Save