Search in sources :

Example 1 with ExcelExporter

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();
    }
}
Also used : ExcelExporter(com.haulmont.cuba.gui.export.ExcelExporter) NotificationType(com.haulmont.cuba.gui.Notifications.NotificationType) ListAction(com.haulmont.cuba.gui.components.actions.ListAction) ExportDisplay(com.haulmont.cuba.gui.export.ExportDisplay) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) ContainerDataUnit(com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit) Messages(com.haulmont.cuba.core.global.Messages) StudioPropertiesItem(com.haulmont.cuba.gui.meta.StudioPropertiesItem) Icons(com.haulmont.cuba.gui.icons.Icons) Collectors(java.util.stream.Collectors) Dialogs(com.haulmont.cuba.gui.Dialogs) Inject(javax.inject.Inject) List(java.util.List) ExcelExportFormat(com.haulmont.cuba.gui.export.ExcelExportFormat) Notifications(com.haulmont.cuba.gui.Notifications) BeanLocator(com.haulmont.cuba.core.global.BeanLocator) ComponentsHelper(com.haulmont.cuba.gui.ComponentsHelper) StudioAction(com.haulmont.cuba.gui.meta.StudioAction) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Entity(com.haulmont.cuba.core.entity.Entity) CollectionContainer(com.haulmont.cuba.gui.model.CollectionContainer) Entity(com.haulmont.cuba.core.entity.Entity) ExcelExporter(com.haulmont.cuba.gui.export.ExcelExporter) ExportDisplay(com.haulmont.cuba.gui.export.ExportDisplay) Notifications(com.haulmont.cuba.gui.Notifications)

Example 2 with ExcelExporter

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();
    }
}
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)2 Messages (com.haulmont.cuba.core.global.Messages)2 Dialogs (com.haulmont.cuba.gui.Dialogs)2 Notifications (com.haulmont.cuba.gui.Notifications)2 NotificationType (com.haulmont.cuba.gui.Notifications.NotificationType)2 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)2 ExcelExportFormat (com.haulmont.cuba.gui.export.ExcelExportFormat)2 ExcelExporter (com.haulmont.cuba.gui.export.ExcelExporter)2 ExportDisplay (com.haulmont.cuba.gui.export.ExportDisplay)2 CubaIcon (com.haulmont.cuba.gui.icons.CubaIcon)2 Icons (com.haulmont.cuba.gui.icons.Icons)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 AppBeans (com.haulmont.cuba.core.global.AppBeans)1 BeanLocator (com.haulmont.cuba.core.global.BeanLocator)1 AppConfig (com.haulmont.cuba.gui.AppConfig)1 ComponentsHelper (com.haulmont.cuba.gui.ComponentsHelper)1 ComponentsHelper.getScreenContext (com.haulmont.cuba.gui.ComponentsHelper.getScreenContext)1 Type (com.haulmont.cuba.gui.components.DialogAction.Type)1 ListAction (com.haulmont.cuba.gui.components.actions.ListAction)1