|
|
|
@ -3,7 +3,6 @@ package com.dsideal.base.Tools.FillData.ExcelKit;
|
|
|
|
|
import com.dsideal.base.DataEase.Model.ExcelReader;
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFFont;
|
|
|
|
@ -352,9 +351,8 @@ public class ExcelKit {
|
|
|
|
|
* @param skipRowCount 跳过的行数
|
|
|
|
|
* @return 结果数据
|
|
|
|
|
* @throws IOException
|
|
|
|
|
* @throws InvalidFormatException
|
|
|
|
|
*/
|
|
|
|
|
public static List<List<String>> getChartDataByXml(String docPath, int chartNumber, int skipRowCount) throws IOException, InvalidFormatException, InterruptedException, DocumentException {
|
|
|
|
|
public static List<List<String>> getChartData(String docPath, int chartNumber, int skipRowCount) throws IOException, DocumentException {
|
|
|
|
|
List<List<String>> data = readChart(docPath, chartNumber);
|
|
|
|
|
//需要跳过前skipRowCount行,先要判断一下是不是够跳的,不够跳的直接输出错误
|
|
|
|
|
if (data == null || data.size() < skipRowCount) {
|
|
|
|
@ -365,28 +363,6 @@ public class ExcelKit {
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<List<String>> readChart(String docPath, int chartNumber, int skipRowCount) throws IOException, InvalidFormatException, DocumentException, InterruptedException {
|
|
|
|
|
return getChartDataByXml(docPath, chartNumber, skipRowCount);
|
|
|
|
|
|
|
|
|
|
// InputStream is = new FileInputStream(docPath);
|
|
|
|
|
// ZipSecureFile.setMinInflateRatio(-1.0d);
|
|
|
|
|
// XWPFDocument doc = new XWPFDocument(is);
|
|
|
|
|
// //排序后的图表
|
|
|
|
|
// List<XWPFChart> charts = ExcelKit.getSortListForXWPFChart(doc.getCharts());
|
|
|
|
|
//
|
|
|
|
|
// if (charts.size() < chartNumber) {
|
|
|
|
|
// System.out.println(docPath + ",没有第" + chartNumber + "个图表,请检查!");
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// XSSFWorkbook workbook = charts.get(chartNumber - 1).getWorkbook();
|
|
|
|
|
// List<List<String>> data = ExcelKit.readSheet(workbook, skipRowCount);
|
|
|
|
|
// is.close();
|
|
|
|
|
// if (data.isEmpty()) {
|
|
|
|
|
// System.out.println(docPath + ",第" + chartNumber + "个图表,存在数据外链接情况,改用XML方式处理!");
|
|
|
|
|
// return getChartDataByXml(docPath, chartNumber, skipRowCount);
|
|
|
|
|
// }
|
|
|
|
|
// return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 读取指定Sheet的第2个表格
|
|
|
|
|