cstyle.setCondition("true");
cell.addStyle(cstyle);
}
private static ExcelManipulatorDefinition generateDefinition(TableModel tableModel){
ExcelManipulatorDefinition definition = new ExcelManipulatorDefinition();
definition.setStyleSheetPosition(1);
List<ExcelSheet> excelSheets = new ArrayList<ExcelSheet>();
ExcelSheet excelSheet = new ExcelSheet();
excelSheet.setDisplayName(tableModel.getModelName());
//add Head Block
ExcelBlock headBlock = new ExcelBlock();
headBlock.setStartRow(0);
headBlock.setStartCol(0);
headBlock.setEndRow(1);
headBlock.setEndCol(tableModel.getColumnNames().length);
ExcelCell titleCell = new ExcelCell();
titleCell.setCellIndex("C1");
titleCell.setDataName("title");
setDefaultStyle(titleCell, TITLE_CELL_INDEX);
headBlock.addCell(titleCell);
for(int i=0; i< tableModel.getColumnNames().length; i++){
ExcelCell labelCell = new ExcelCell();
labelCell.setRow(1);
labelCell.setCol(i+1);
labelCell.setDataName("__column" + (i+1));
setDefaultStyle(labelCell, LABEL_CELL_INDEX);
headBlock.addCell(labelCell);
}
excelSheet.addExcelBlock(headBlock);
//add Body Block
ExcelBlock bodyBlock = new ExcelBlock();
bodyBlock.setStartRow(2);
bodyBlock.setStartCol(1);
bodyBlock.setEndRow(2);
bodyBlock.setEndCol(tableModel.getColumnNames().length);
bodyBlock.setLoop(true);
bodyBlock.setDataName("__columns");
for(int i=0; i< tableModel.getColumnNames().length; i++){
ExcelCell cell = new ExcelCell();
cell.setRow(2);
cell.setCol(i+1);
cell.setDataName(tableModel.getColumns()[i]);
setDefaultStyle(cell);
bodyBlock.addCell(cell);
}
excelSheet.addExcelBlock(bodyBlock);
excelSheets.add(excelSheet);
definition.setExcelSheets(excelSheets);
return definition;
}