Search in sources :

Example 1 with ExportMode

use of com.haulmont.cuba.gui.export.ExcelExporter.ExportMode 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();
    }
}
Also used : ExcelExporter(com.haulmont.cuba.gui.export.ExcelExporter) NotificationType(com.haulmont.cuba.gui.Notifications.NotificationType) Type(com.haulmont.cuba.gui.components.DialogAction.Type) ExportDisplay(com.haulmont.cuba.gui.export.ExportDisplay) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) ComponentsHelper.getScreenContext(com.haulmont.cuba.gui.ComponentsHelper.getScreenContext) Messages(com.haulmont.cuba.core.global.Messages) AppBeans(com.haulmont.cuba.core.global.AppBeans) Icons(com.haulmont.cuba.gui.icons.Icons) Collectors(java.util.stream.Collectors) Dialogs(com.haulmont.cuba.gui.Dialogs) Scope(org.springframework.context.annotation.Scope) List(java.util.List) ExportMode(com.haulmont.cuba.gui.export.ExcelExporter.ExportMode) AppConfig(com.haulmont.cuba.gui.AppConfig) ExcelExportFormat(com.haulmont.cuba.gui.export.ExcelExportFormat) Notifications(com.haulmont.cuba.gui.Notifications) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Entity(com.haulmont.cuba.core.entity.Entity) Entity(com.haulmont.cuba.core.entity.Entity) ExcelExporter(com.haulmont.cuba.gui.export.ExcelExporter) Notifications(com.haulmont.cuba.gui.Notifications)

Aggregations

Entity (com.haulmont.cuba.core.entity.Entity)1 AppBeans (com.haulmont.cuba.core.global.AppBeans)1 Messages (com.haulmont.cuba.core.global.Messages)1 AppConfig (com.haulmont.cuba.gui.AppConfig)1 ComponentsHelper.getScreenContext (com.haulmont.cuba.gui.ComponentsHelper.getScreenContext)1 Dialogs (com.haulmont.cuba.gui.Dialogs)1 Notifications (com.haulmont.cuba.gui.Notifications)1 NotificationType (com.haulmont.cuba.gui.Notifications.NotificationType)1 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)1 Type (com.haulmont.cuba.gui.components.DialogAction.Type)1 ExcelExportFormat (com.haulmont.cuba.gui.export.ExcelExportFormat)1 ExcelExporter (com.haulmont.cuba.gui.export.ExcelExporter)1 ExportMode (com.haulmont.cuba.gui.export.ExcelExporter.ExportMode)1 ExportDisplay (com.haulmont.cuba.gui.export.ExportDisplay)1 CubaIcon (com.haulmont.cuba.gui.icons.CubaIcon)1 Icons (com.haulmont.cuba.gui.icons.Icons)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Scope (org.springframework.context.annotation.Scope)1