Package org.eclipse.nebula.widgets.nattable.extension.poi

Examples of org.eclipse.nebula.widgets.nattable.extension.poi.HSSFExcelExporter


        });
        natTable.addConfiguration(new AbstractRegistryConfiguration() {
            public void configureRegistry(IConfigRegistry configRegistry) {
                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.EXPORTER,
                        new HSSFExcelExporter());
            }
        });

        // Column group header menu
        final Menu columnGroupHeaderMenu = new PopupMenuBuilder(natTable)
View Full Code Here


        // adding this configuration adds the styles and the painters to use
        natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
        natTable.addConfiguration(new AbstractRegistryConfiguration() {
            @Override
            public void configureRegistry(IConfigRegistry configRegistry) {
                PoiExcelExporter exporter = new HSSFExcelExporter();
                exporter.setApplyVerticalTextConfiguration(true);
                exporter.setApplyBackgroundColor(false);
                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.EXPORTER, exporter);

                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.DATE_FORMAT, "dd.MM.yyyy");
View Full Code Here

        natTable.addConfiguration(new AbstractRegistryConfiguration() {
            @Override
            public void configureRegistry(IConfigRegistry configRegistry) {
                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.EXPORTER,
                        new HSSFExcelExporter());

                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.DATE_FORMAT, "dd.MM.yyyy");

                // register a custom formatter to the body of the grid
                // you could also implement different formatter for different
                // columns by using the label mechanism
                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.EXPORT_FORMATTER,
                        new ExampleExportFormatter(), DisplayMode.NORMAL,
                        GridRegion.BODY);

                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.EXPORT_FORMATTER,
                        new IExportFormatter() {
                            @Override
                            public Object formatForExport(ILayerCell cell,
                                    IConfigRegistry configRegistry) {
                                // simply return the data value which is an
                                // integer for the row header
                                // doing this avoids the default conversion to
                                // string for export
                                return cell.getDataValue();
                            }
                        }, DisplayMode.NORMAL, GridRegion.ROW_HEADER);
            }
        });

        natTable.configure();

        GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);

        // property names of the NumberValues class
        String[] numberPropertyNames = { "columnOneNumber", "columnTwoNumber",
                "columnThreeNumber", "columnFourNumber", "columnFiveNumber" };

        // mapping from property to label, needed for column header labels
        Map<String, String> numberPropertyToLabelMap = new HashMap<String, String>();
        numberPropertyToLabelMap.put("columnOneNumber", "Value One");
        numberPropertyToLabelMap.put("columnTwoNumber", "Value Two");
        numberPropertyToLabelMap.put("columnThreeNumber", "Value Three");
        numberPropertyToLabelMap.put("columnFourNumber", "Value Four");
        numberPropertyToLabelMap.put("columnFiveNumber", "Value Five");

        List<NumberValues> valuesToShow = new ArrayList<NumberValues>();
        valuesToShow.add(createNumberValues());
        valuesToShow.add(createNumberValues());
        valuesToShow.add(createNumberValues());
        valuesToShow.add(createNumberValues());
        valuesToShow.add(createNumberValues());

        final NatTable numberNatTable = new NatTable(gridPanel, createGrid(
                numberPropertyNames, numberPropertyToLabelMap, valuesToShow),
                false);

        // adding this configuration adds the styles and the painters to use
        numberNatTable
                .addConfiguration(new DefaultNatTableStyleConfiguration());
        numberNatTable.addConfiguration(new AbstractRegistryConfiguration() {
            @Override
            public void configureRegistry(IConfigRegistry configRegistry) {

                // register a custom formatter to the body of the grid
                // you could also implement different formatter for different
                // columns by using the label mechanism
                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.EXPORT_FORMATTER,
                        new IExportFormatter() {
                            @Override
                            public Object formatForExport(ILayerCell cell,
                                    IConfigRegistry configRegistry) {
                                // simply return the data value which is an
                                // integer for the row header
                                // doing this avoids the default conversion to
                                // string for export
                                return cell.getDataValue();
                            }
                        }, DisplayMode.NORMAL, GridRegion.BODY);

                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.EXPORT_FORMATTER,
                        new IExportFormatter() {
                            @Override
                            public Object formatForExport(ILayerCell cell,
                                    IConfigRegistry configRegistry) {
                                // simply return the data value which is an
                                // integer for the row header
                                // doing this avoids the default conversion to
                                // string for export
                                return cell.getDataValue();
                            }
                        }, DisplayMode.NORMAL, GridRegion.ROW_HEADER);
            }
        });

        numberNatTable.configure();
        GridDataFactory.fillDefaults().grab(true, true).applyTo(numberNatTable);

        Button addColumnButton = new Button(buttonPanel, SWT.PUSH);
        addColumnButton.setText("Export");
        addColumnButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                Map<String, NatTable> export = new HashMap<String, NatTable>();
                export.put("Persons", natTable);
                export.put("Numbers", numberNatTable);
                new NatExporter(Display.getCurrent().getActiveShell())
                        .exportMultipleNatTables(new HSSFExcelExporter(),
                                export);
            }
        });

        return panel;
View Full Code Here

        natTable.addConfiguration(new AbstractRegistryConfiguration() {
            @Override
            public void configureRegistry(IConfigRegistry configRegistry) {
                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.EXPORTER,
                        new HSSFExcelExporter());
            }
        });
        natTable.addConfiguration(new FilterRowCustomConfiguration());

        natTable.setConfigRegistry(configRegistry);
View Full Code Here

TOP

Related Classes of org.eclipse.nebula.widgets.nattable.extension.poi.HSSFExcelExporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.