use of com.alibaba.excel.write.metadata.MapRowData in project easyexcel by alibaba.
the class ExcelWriteAddExecutor method addOneRowOfDataToExcel.
private void addOneRowOfDataToExcel(Object oneRowData, int rowIndex, int relativeRowIndex, Map<Integer, Field> sortedAllFieldMap) {
if (oneRowData == null) {
return;
}
RowWriteHandlerContext rowWriteHandlerContext = WriteHandlerUtils.createRowWriteHandlerContext(writeContext, rowIndex, relativeRowIndex, Boolean.FALSE);
WriteHandlerUtils.beforeRowCreate(rowWriteHandlerContext);
Row row = WorkBookUtil.createRow(writeContext.writeSheetHolder().getSheet(), rowIndex);
rowWriteHandlerContext.setRow(row);
WriteHandlerUtils.afterRowCreate(rowWriteHandlerContext);
if (oneRowData instanceof Collection<?>) {
addBasicTypeToExcel(new CollectionRowData((Collection<?>) oneRowData), row, rowIndex, relativeRowIndex);
} else if (oneRowData instanceof Map) {
addBasicTypeToExcel(new MapRowData((Map<Integer, ?>) oneRowData), row, rowIndex, relativeRowIndex);
} else {
addJavaObjectToExcel(oneRowData, row, rowIndex, relativeRowIndex, sortedAllFieldMap);
}
WriteHandlerUtils.afterRowDispose(rowWriteHandlerContext);
}
Aggregations