Search in sources :

Example 1 with HeaderDemo2

use of com.hummer.excel.plugin.test.model.HeaderDemo2 in project hummer-framework by hummer-team.

the class ReaderTest method testTableExcel.

@Test
public void testTableExcel() {
    List<TableWriteDataBo> list = new ArrayList<>(2);
    TableWriteDataBo bo = new TableWriteDataBo();
    bo.setHeadClass(HeaderDemo.class);
    bo.setDataInfos(data(1, HeaderDemo.class));
    TableWriteDataBo bo2 = new TableWriteDataBo();
    bo2.setHeadClass(HeaderDemo2.class);
    bo2.setDataInfos(data(5, HeaderDemo2.class));
    list.add(bo);
    list.add(bo2);
    String sheet = "模板";
    String fileName = TestFileUtil.getPath() + "tableWrite" + System.currentTimeMillis() + ".xlsx";
    File file = new File(fileName);
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(file);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    TableWriteTemplate.getInstance().tableWrite(list, sheet, outputStream);
}
Also used : FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) HeaderDemo(com.hummer.excel.plugin.test.model.HeaderDemo) HeaderDemo2(com.hummer.excel.plugin.test.model.HeaderDemo2) File(java.io.File) TableWriteDataBo(com.hummer.excel.plugin.model.write.TableWriteDataBo) Test(org.junit.Test)

Aggregations

TableWriteDataBo (com.hummer.excel.plugin.model.write.TableWriteDataBo)1 HeaderDemo (com.hummer.excel.plugin.test.model.HeaderDemo)1 HeaderDemo2 (com.hummer.excel.plugin.test.model.HeaderDemo2)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1