diff --git a/test/com/platform/test/ExcelTest.java b/test/com/platform/test/ExcelTest.java new file mode 100644 index 00000000..2cfaf773 --- /dev/null +++ b/test/com/platform/test/ExcelTest.java @@ -0,0 +1,49 @@ +package com.platform.test; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Test; + +import com.base.Constant; +import com.platform.entities.PreDataInfo; +import com.platform.utils.excelUtils.ExcelOperation; + +public class ExcelTest { + + @Test + public void writeData() { + PreDataInfo info = new PreDataInfo(); + info.setAnalysisOfFinancialEconomicProsperity("否"); + info.setAreaCode("321167"); + info.setBeginUseTime("201107"); + List list = new ArrayList(); + list.add(info); + XSSFWorkbook result = null; + try { + result = ExcelOperation.readExcelTemplate(Constant.SYSTEM_INFO_EXCEL_TEMPLATE_FIEL_PATH, list); + } catch (IllegalArgumentException + | IllegalAccessException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("----"+result); + + try { + FileOutputStream fileOut =new FileOutputStream(new File("D:/test/3.xlsx")); + result.write(fileOut); + fileOut.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +}