diff --git a/test/com/platform/test/ExcelTest.java b/test/com/platform/test/ExcelTest.java index 2cfaf773..8988970c 100644 --- a/test/com/platform/test/ExcelTest.java +++ b/test/com/platform/test/ExcelTest.java @@ -5,6 +5,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Date; import java.util.List; import org.apache.poi.hssf.usermodel.HSSFWorkbook; @@ -19,15 +20,20 @@ public class ExcelTest { @Test public void writeData() { + Date date = new Date(); PreDataInfo info = new PreDataInfo(); info.setAnalysisOfFinancialEconomicProsperity("否"); info.setAreaCode("321167"); info.setBeginUseTime("201107"); + info.setFunctionDetails("这是一个神奇的功能"); List list = new ArrayList(); - list.add(info); + for (int i = 0; i < 400; i++) { + list.add(info); + } + XSSFWorkbook result = null; try { - result = ExcelOperation.readExcelTemplate(Constant.SYSTEM_INFO_EXCEL_TEMPLATE_FIEL_PATH, list); + result = ExcelOperation.writeExcelTemplate(Constant.SYSTEM_INFO_EXCEL_TEMPLATE_FIEL_PATH, list); } catch (IllegalArgumentException | IllegalAccessException | IOException e) { // TODO Auto-generated catch block @@ -36,14 +42,22 @@ public class ExcelTest { System.out.println("----"+result); try { - FileOutputStream fileOut =new FileOutputStream(new File("D:/test/3.xlsx")); - result.write(fileOut); - fileOut.close(); + File f = new File("D:/test/4.xlsx"); + FileOutputStream fileOut = null; + if (f.exists()) { + fileOut = new FileOutputStream(f); + result.write(fileOut); + fileOut.close(); + } + else { + System.out.println("no file"); + } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - + Date date2 = new Date(); + System.out.println("complete: "+ (date2.getTime()-date.getTime())); } }