@SuppressWarnings("unchecked")
public void export(String dataTableId, String type)
{
excelWorkbook = ExcelFactory.instance().getExcelWorkbook(type);
CSSParser parser = new CSSParser();
// Gets the datatable
UIData dataTable = (UIData) FacesContext.getCurrentInstance().getViewRoot().findComponent(dataTableId);
if (dataTable == null)
{
throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not find data table with id #0", dataTableId));
}
// Inits the workbook and worksheet
UIWorkbook uiWorkbook = new UIWorkbook();
excelWorkbook.createWorkbook(uiWorkbook);
UIWorksheet uiWorksheet = new UIWorksheet();
uiWorkbook.getChildren().add(uiWorksheet);
uiWorksheet.setStyle(CSSParser.getStyle(dataTable));
uiWorksheet.setStyleClass(CSSParser.getStyleClass(dataTable));
excelWorkbook.createOrSelectWorksheet(uiWorksheet);
// Saves the datatable var
String dataTableVar = dataTable.getVar();
Object oldValue = FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(dataTableVar);
// Processes the columns
List<javax.faces.component.UIColumn> columns = ExcelComponent.getChildrenOfType(dataTable.getChildren(), javax.faces.component.UIColumn.class);
columnWidths = parseColumnWidths(uiWorksheet);
int col = 0;
for (javax.faces.component.UIColumn column : columns)
{
ColumnStyle columnStyle = new ColumnStyle(parser.getCascadedStyleMap(column));
boolean cssExport = columnStyle.export == null || columnStyle.export;
if (column.isRendered() && cssExport)
{
uiWorksheet.getChildren().add(column);
Iterator iterator = UIWorksheet.unwrapIterator(dataTable.getValue());