public class WasteExcel {
// public static String path = “C:\Users\my\Desktop\weixin2\IMDY\upload\”;
//public static String path = “/Users/weixj/Desktop/wph/IMDY/upload”;
public static String path = "upload";
// public static String mdlpath = path+"/template/"+ “【导出】废弃物处理模板.xlsx”;
//public static String mdlpath = “/Users/weixj/Desktop/解压/vehicleCharge-1/templeteWord/隐患排查治理.xlsx”;
//在这里主函数只是用来测试调用,直接调用getXLsx
public static void main(String[] args) throws IOException {
List<List<String[]>> tabledataList = new ArrayList<>();
List<String[]> sheet1 = new ArrayList<String[]>();
for (int i = 0; i < 30; i++) {
sheet1.add(new String[] { “2020-09-09”, “餐厨垃圾”, “10桶”, “张三”, “回收单位”, “回收人员”, “备注” });
}
tabledataList.add(sheet1);
getXLsx(sheet1,“pp”,“2019-10”,133);
}
public static String getXLsx(List<String[]> table1, String mdlpath, String fileName, Integer businessId) throws IOException {
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM");
String currentTime = dateFormat.format( now );
try (FileInputStream is = new FileInputStream(path+mdlpath);
XSSFWorkbook workBook = new XSSFWorkbook(is)) {
XSSFSheet sheet1 = workBook.getSheetAt(0); //获取第一页
// List<String[]> table1 = tabledataList.get(0);
if (table1.size() > 24) {
//插入行
Row startRow = sheet1.getRow(2);
//Row newRow=sheet1.create