|
@@ -3,6 +3,7 @@ package com.galaxis.manatee.Test.zzx;
|
|
|
import com.galaxis.manatee.entity.chuanyun.data.object.Handbook;
|
|
|
import com.galaxis.manatee.entity.chuanyun.data.object.MyExcelData;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
@@ -29,8 +30,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
*/
|
|
|
public class ProjectTest2 {
|
|
|
public static void main(String[] args) {
|
|
|
- List<List<Object>> excel1 = getExcel("C:\\Users\\86186\\Desktop\\分权手册2022_09_21_16_33_42.xlsx");
|
|
|
- List<List<Object>> excel2 = getExcel("C:\\Users\\86186\\Desktop\\凯捷--2022年度分级授权手册20220920更新了花名册.xls");
|
|
|
+ List<List<Object>> excel1 = getExcel("C:\\Users\\mayn\\Desktop\\分权手册2022_09_21_16_33_42.xlsx");
|
|
|
+ List<List<Object>> excel2 = getExcel("C:\\Users\\mayn\\Desktop\\凯捷--2022年度分级授权手册20220920更新了花名册(1).xls");
|
|
|
|
|
|
// 最新的h2分权手册
|
|
|
List<MyExcelData> excelDataList = new ArrayList<>();
|
|
@@ -96,7 +97,8 @@ public class ProjectTest2 {
|
|
|
// System.err.println(handbookList.toString());
|
|
|
// System.err.println(handbookList.get(609)); //刘东升
|
|
|
|
|
|
- toTxt(handbookList);
|
|
|
+ // toTxt(handbookList);
|
|
|
+ toExcel(handbookList);
|
|
|
}
|
|
|
|
|
|
//将List导出成Excel
|
|
@@ -105,8 +107,7 @@ public class ProjectTest2 {
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
|
|
|
//创建一个sheet
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd");
|
|
|
- HSSFSheet sheet = workbook.createSheet("更新过后的分权手册" + simpleDateFormat.format(new Date()));
|
|
|
+ HSSFSheet sheet = workbook.createSheet("更新过后的分权手册");
|
|
|
|
|
|
//在sheet表中添加0行
|
|
|
HSSFRow row = sheet.createRow(0);
|
|
@@ -196,7 +197,8 @@ public class ProjectTest2 {
|
|
|
row1.createCell(18).setCellValue(handbook.getF0000012());
|
|
|
}
|
|
|
|
|
|
- File file = new File("C:/Users/86186/Desktop/test.txt");
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYYMMddHHmmss");
|
|
|
+ File file = new File("C:/Users/mayn/Desktop/更新过后的分权手册" + simpleDateFormat.format(new Date()) + ".xls");
|
|
|
if (file.exists()) {
|
|
|
file.delete();
|
|
|
}
|
|
@@ -204,9 +206,10 @@ public class ProjectTest2 {
|
|
|
//将文件保存到指定的位置
|
|
|
try {
|
|
|
file.createNewFile();
|
|
|
-// workbook.write(file);
|
|
|
+ FileOutputStream outputStream = FileUtils.openOutputStream(file);
|
|
|
+ workbook.write(outputStream);
|
|
|
System.out.println("导出到成功");
|
|
|
- System.out.println("默认位置:C:/Users/86186/Desktop/test.txt");
|
|
|
+ System.out.println("默认位置:C:/Users/mayn/Desktop/更新过后的分权手册" + simpleDateFormat.format(new Date()) + ".xls");
|
|
|
workbook.close();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
@@ -233,7 +236,6 @@ public class ProjectTest2 {
|
|
|
Workbook wb = null;
|
|
|
Sheet sheet = null;
|
|
|
Row row = null;
|
|
|
-
|
|
|
wb = readExcel(filePath);
|
|
|
|
|
|
List<List<List<Object>>> list = new ArrayList<>();
|
|
@@ -322,9 +324,4 @@ public class ProjectTest2 {
|
|
|
}
|
|
|
return cellvalue;
|
|
|
}
|
|
|
-
|
|
|
- public static Boolean isNotNull(List<Object> objects, int index) {
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
}
|