use of com.haulmont.cuba.gui.export.ExcelExporter in project cuba by cuba-platform.
the class ExcelAction method export.
/**
* Export via {@link ExcelExporter}.
*/
protected void export(ExcelExporter.ExportMode exportMode) {
ExcelExporter exporter = new ExcelExporter(exportFormat);
exporter.setExportAggregation(exportAggregation);
Window window = ComponentsHelper.getWindowNN(target);
ExportDisplay display = beanLocator.get(ExportDisplay.NAME);
display.setFrame(window);
if (target instanceof Table) {
@SuppressWarnings("unchecked") Table<Entity> table = (Table<Entity>) target;
exporter.exportTable(table, table.getNotCollapsedColumns(), false, display, null, fileName, exportMode);
}
if (target instanceof DataGrid) {
@SuppressWarnings("unchecked") DataGrid<Entity> dataGrid = (DataGrid<Entity>) target;
List<DataGrid.Column> columns = dataGrid.getVisibleColumns().stream().filter(col -> !col.isCollapsed()).collect(Collectors.toList());
exporter.exportDataGrid(dataGrid, columns, display, null, fileName, exportMode);
}
if (exporter.isXlsMaxRowNumberExceeded()) {
Notifications notifications = ComponentsHelper.getScreenContext(target).getNotifications();
notifications.create(NotificationType.WARNING).withCaption(messages.getMainMessage("actions.warningExport.title")).withDescription(messages.getMainMessage("actions.warningExport.message")).show();
}
}
use of com.haulmont.cuba.gui.export.ExcelExporter in project cuba by cuba-platform.
the class ExcelAction method export.
/**
* Export via {@link ExcelExporter}.
*/
protected void export(ExportMode exportMode) {
ExcelExporter exporter = new ExcelExporter(exportFormat);
exporter.setExportAggregation(exportAggregation);
if (listComponent instanceof Table) {
Table<Entity> table = (Table<Entity>) listComponent;
exporter.exportTable(table, table.getNotCollapsedColumns(), false, display, null, fileName, exportMode);
}
if (listComponent instanceof DataGrid) {
DataGrid<Entity> dataGrid = (DataGrid<Entity>) listComponent;
List<DataGrid.Column> columns = dataGrid.getVisibleColumns().stream().filter(col -> !col.isCollapsed()).collect(Collectors.toList());
exporter.exportDataGrid(dataGrid, columns, display, null, fileName, exportMode);
}
if (exporter.isXlsMaxRowNumberExceeded()) {
Notifications notifications = getScreenContext(listComponent).getNotifications();
notifications.create(NotificationType.WARNING).withCaption(messages.getMainMessage("actions.warningExport.title")).withDescription(messages.getMainMessage("actions.warningExport.message")).show();
}
}
Aggregations