|
|
|
@ -31,7 +31,7 @@ public class DsKit {
|
|
|
|
|
* @param sourceExcel
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
public static String ConvertXlsToXlsx(String sourceExcel) throws IOException {
|
|
|
|
|
public static String convertXlsToXlsx(String sourceExcel) throws IOException {
|
|
|
|
|
if (sourceExcel.endsWith(".xls")) {
|
|
|
|
|
ExcelUtil.xlsChangeXlsx(sourceExcel, sourceExcel + "x");
|
|
|
|
|
//删除旧的文件
|
|
|
|
@ -124,7 +124,7 @@ public class DsKit {
|
|
|
|
|
* @param outWorkbook
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static XSSFSheet CreateSheet(XSSFWorkbook outWorkbook) {
|
|
|
|
|
public static XSSFSheet createSheet(XSSFWorkbook outWorkbook) {
|
|
|
|
|
XSSFSheet outSheet = outWorkbook.createSheet("Sheet1");
|
|
|
|
|
//保存Excel
|
|
|
|
|
outSheet.setDefaultColumnWidth(20);
|
|
|
|
@ -355,7 +355,7 @@ public class DsKit {
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
public static List<List<String>> getChartData(String docPath, int chartNumber, int skipRowCount) throws IOException, DocumentException, InterruptedException, InvalidFormatException {
|
|
|
|
|
DsKit.UnCompress(docPath);
|
|
|
|
|
DsKit.unCompress(docPath);
|
|
|
|
|
List<List<String>> data = readChartByXml(docPath, chartNumber);
|
|
|
|
|
//需要跳过前skipRowCount行,先要判断一下是不是够跳的,不够跳的直接输出错误
|
|
|
|
|
if (data.size() < skipRowCount) {
|
|
|
|
@ -397,7 +397,7 @@ public class DsKit {
|
|
|
|
|
*/
|
|
|
|
|
public static List<List<String>> readSecondTable(String filePath, int sheetIndex,
|
|
|
|
|
String keyword, int headRows, int tableWidth) throws IOException {
|
|
|
|
|
filePath = ConvertXlsToXlsx(filePath);
|
|
|
|
|
filePath = convertXlsToXlsx(filePath);
|
|
|
|
|
List<List<String>> dataList = new ArrayList<>();
|
|
|
|
|
FileInputStream fis = new FileInputStream(filePath);
|
|
|
|
|
Workbook workbook = new XSSFWorkbook(fis);
|
|
|
|
@ -483,7 +483,7 @@ public class DsKit {
|
|
|
|
|
*
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
public static void UnCompress(String wordPath) throws IOException {
|
|
|
|
|
public static void unCompress(String wordPath) throws IOException {
|
|
|
|
|
if (new File(DocxUnzipDirectory).exists()) {
|
|
|
|
|
FileUtils.deleteDirectory(new File(DocxUnzipDirectory));
|
|
|
|
|
}
|
|
|
|
@ -524,7 +524,7 @@ public class DsKit {
|
|
|
|
|
*/
|
|
|
|
|
public static List<List<String>> readChartByXml(String sourceDoc, int chartNumber) throws DocumentException, IOException {
|
|
|
|
|
//将word文件解压缩
|
|
|
|
|
UnCompress(sourceDoc);
|
|
|
|
|
unCompress(sourceDoc);
|
|
|
|
|
List<List<String>> matrix = new ArrayList<>();
|
|
|
|
|
String xml = DocxUnzipDirectory + "word\\charts\\chart" + chartNumber + ".xml";
|
|
|
|
|
if (!(new File(xml).exists())) {
|
|
|
|
|