src/main/java/org/braisdom/excel/WorkbookTemplate.java
private int processDataTableElement(int rowIndex, Element dataTableElement, SheetWriter sheetWriter) {
        Element headerElement = dataTableElement.element(WorkbookElement.HEADER.getValue());
        Element bodyElement = dataTableElement.element(WorkbookElement.BODY.getValue());

        Map<Element, Boolean> fitColumns = new HashMap<>();

        int dataTableRowIndex = rowIndex;
        int headerRowCount = 0;
        int columnCount = -1;
        boolean fitContent = false;

        if (headerElement != null) {
            List<Element> rowElements = headerElement.elements(WorkbookElement.ROW.getValue());
            for (int headerRowIndex = 0; headerRowIndex < rowElements.size(); headerRowIndex++) {
                Element rowElement = rowElements.get(headerRowIndex);
                int assignedRowGaps = StyleUtils.safeInteger(rowElement.attributeValue(WorkbookAttribute.ROW_GAPS.getValue()));
                columnCount = rowElement.elements(WorkbookElement.CELL.getValue()).size();
                fitContent = Boolean.valueOf(rowElement.attributeValue(WorkbookAttribute.FIT_CONTENT.getValue()));

                dataTableRowIndex += assignedRowGaps;
                processRowElement(dataTableRowIndex + headerRowCount, rowElement, sheetWriter);
                headerRowCount++;
            }
        }

        if (bodyElement != null) {
            List<Element> rowElements = bodyElement.elements(WorkbookElement.ROW.getValue());

            for (int bodyRowIndex = 0; bodyRowIndex < rowElements.size(); bodyRowIndex++) {
                Element rowElement = rowElements.get(bodyRowIndex);
                int assignedRowGaps = StyleUtils.safeInteger(rowElement.attributeValue(WorkbookAttribute.ROW_GAPS.getValue()));
                dataTableRowIndex += assignedRowGaps;
                processRowElement(dataTableRowIndex + headerRowCount + bodyRowIndex, rowElement, sheetWriter);
            }
        }

        // Resize the column width finally because the POI performance problem.
        if (fitContent) {
            for (int i = 0; i < columnCount; i++) {
                sheetWriter.autoSizeColumn(i);
            }
        }

        return dataTableRowIndex;
    }
/**
     * Parsing the data-table tags and generating the rows and cells of Excel
     *
     * @param rowIndex         current row index of Excel
     * @param dataTableElement the data table definition
     * @param sheetWriter      the sheet writer of Excel
     * @return
     */
Parsing the data-table tags and generating the rows and cells of Excel
@param rowIndex         current row index of Excel
@param dataTableElement the data table definition
@param sheetWriter      the sheet writer of Excel
@return
Parsing the data - table tags and generating the rows and cells of Excel @param rowIndex current row index of Excel @param dataTableElement the data table definition @param sheetWriter the sheet writer of Excel @return
private int processDataTableElement(int rowIndex, Element dataTableElement, SheetWriter sheetWriter) {
        Element headerElement = dataTableElement.element(WorkbookElement.HEADER.getValue());
        Element bodyElement = dataTableElement.element(WorkbookElement.BODY.getValue());
        Map<Element, Boolean> fitColumns = new HashMap<>();
        int dataTableRowIndex = rowIndex;
        int headerRowCount = 0;
        int columnCount = -1;
        boolean fitContent = false;
        if (headerElement != null) {
            List<Element> rowElements = headerElement.elements(WorkbookElement.ROW.getValue());
            for (int headerRowIndex = 0; headerRowIndex < rowElements.size(); headerRowIndex++) {
                Element rowElement = rowElements.get(headerRowIndex);
                int assignedRowGaps = StyleUtils.safeInteger(rowElement.attributeValue(WorkbookAttribute.ROW_GAPS.getValue()));
                columnCount = rowElement.elements(WorkbookElement.CELL.getValue()).size();
                fitContent = Boolean.valueOf(rowElement.attributeValue(WorkbookAttribute.FIT_CONTENT.getValue()));
                dataTableRowIndex += assignedRowGaps;
                processRowElement(dataTableRowIndex + headerRowCount, rowElement, sheetWriter);
                headerRowCount++;
            }
        }
        if (bodyElement != null) {
            List<Element> rowElements = bodyElement.elements(WorkbookElement.ROW.getValue());
            for (int bodyRowIndex = 0; bodyRowIndex < rowElements.size(); bodyRowIndex++) {
                Element rowElement = rowElements.get(bodyRowIndex);
                int assignedRowGaps = StyleUtils.safeInteger(rowElement.attributeValue(WorkbookAttribute.ROW_GAPS.getValue()));
                dataTableRowIndex += assignedRowGaps;
                processRowElement(dataTableRowIndex + headerRowCount + bodyRowIndex, rowElement, sheetWriter);
            }
        }
        if (fitContent) {
            for (int i = 0; i < columnCount; i++) {
                sheetWriter.autoSizeColumn(i);
            }
        }
        return dataTableRowIndex;
    }
private int processDataTableElement ( int rowIndex , Element dataTableElement , SheetWriter sheetWriter ) { Element headerElement = dataTableElement . element ( WorkbookElement . HEADER . getValue ( ) ) ; Element bodyElement = dataTableElement . element ( WorkbookElement . BODY . getValue ( ) ) ; Map < Element , Boolean > fitColumns = new HashMap < > ( ) ; int dataTableRowIndex = rowIndex ; int headerRowCount = 0 ; int columnCount = - 1 ; boolean fitContent = false ; if ( headerElement != null ) { List < Element > rowElements = headerElement . elements ( WorkbookElement . ROW . getValue ( ) ) ; for ( int headerRowIndex = 0 ; headerRowIndex < rowElements . size ( ) ; headerRowIndex ++ ) { Element rowElement = rowElements . get ( headerRowIndex ) ; int assignedRowGaps = StyleUtils . safeInteger ( rowElement . attributeValue ( WorkbookAttribute . ROW_GAPS . getValue ( ) ) ) ; columnCount = rowElement . elements ( WorkbookElement . CELL . getValue ( ) ) . size ( ) ; fitContent = Boolean . valueOf ( rowElement . attributeValue ( WorkbookAttribute . FIT_CONTENT . getValue ( ) ) ) ; dataTableRowIndex += assignedRowGaps ; processRowElement ( dataTableRowIndex + headerRowCount , rowElement , sheetWriter ) ; headerRowCount ++ ; } } if ( bodyElement != null ) { List < Element > rowElements = bodyElement . elements ( WorkbookElement . ROW . getValue ( ) ) ; for ( int bodyRowIndex = 0 ; bodyRowIndex < rowElements . size ( ) ; bodyRowIndex ++ ) { Element rowElement = rowElements . get ( bodyRowIndex ) ; int assignedRowGaps = StyleUtils . safeInteger ( rowElement . attributeValue ( WorkbookAttribute . ROW_GAPS . getValue ( ) ) ) ; dataTableRowIndex += assignedRowGaps ; processRowElement ( dataTableRowIndex + headerRowCount + bodyRowIndex , rowElement , sheetWriter ) ; } } if ( fitContent ) { for ( int i = 0 ; i < columnCount ; i ++ ) { sheetWriter . autoSizeColumn ( i ) ; } } return dataTableRowIndex ; }
Parsing the data-table tags and generating the rows and cells of Excel
 @param rowIndex         current row index of Excel
 @param dataTableElement the data table definition
 @param sheetWriter      the sheet writer of Excel
 @return
Parsing the data - table tags and generating the rows and cells of Excel @param rowIndex current row index of Excel @param dataTableElement the data table definition @param sheetWriter the sheet writer of Excel @return
// Resize the column width finally because the POI performance problem.