You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
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<PreDataInfo> list = new ArrayList<PreDataInfo>();
|
|
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();
|
|
}
|
|
|
|
}
|
|
|
|
}
|