Search in sources :

Example 1 with Sheet

use of com.hccake.common.excel.annotation.Sheet in project ballcat by ballcat-projects.

the class ManySheetWriteHandler method write.

@Override
public void write(Object obj, HttpServletResponse response, ResponseExcel responseExcel) {
    List<?> objList = (List<?>) obj;
    ExcelWriter excelWriter = getExcelWriter(response, responseExcel);
    Sheet[] sheets = responseExcel.sheets();
    WriteSheet sheet;
    for (int i = 0; i < sheets.length; i++) {
        List<?> eleList = (List<?>) objList.get(i);
        Class<?> dataClass = eleList.get(0).getClass();
        // 创建sheet
        sheet = this.sheet(sheets[i], dataClass, responseExcel.template(), responseExcel.headGenerator());
        // 写入sheet
        excelWriter.write(eleList, sheet);
    }
    excelWriter.finish();
}
Also used : ExcelWriter(com.alibaba.excel.ExcelWriter) WriteSheet(com.alibaba.excel.write.metadata.WriteSheet) List(java.util.List) Sheet(com.hccake.common.excel.annotation.Sheet) WriteSheet(com.alibaba.excel.write.metadata.WriteSheet)

Aggregations

ExcelWriter (com.alibaba.excel.ExcelWriter)1 WriteSheet (com.alibaba.excel.write.metadata.WriteSheet)1 Sheet (com.hccake.common.excel.annotation.Sheet)1 List (java.util.List)1