1

我是 Vaadin 的新手。此时我遇到问题 ExcelExport。

当我单击按钮时,它没有下载文件,也没有显示任何错误。

我不知道这个文件的位置是什么。

final ThemeResource export = new ThemeResource("adminicons/green.png");
    final Button excelExportButton = new Button("Export to Excel");

    public TestExport() {


        final Table table = new Table("This is my Table");
      HorizontalLayout vlaLayout = new HorizontalLayout();

      table.addContainerProperty("First Name", String.class,  null);
      table.addContainerProperty("Last Name",  String.class,  null);
      table.addContainerProperty("Year",       Integer.class, null);

      table.addItem(new Object[] {
          "Nicolaus","Copernicus",new Integer(1473)}, new Integer(1));
      table.addItem(new Object[] {
          "Tycho",   "Brahe",     new Integer(1546)}, new Integer(2));
      table.addItem(new Object[] {
          "Giordano","Bruno",     new Integer(1548)}, new Integer(3));
      table.addItem(new Object[] {
          "Galileo", "Galilei",   new Integer(1564)}, new Integer(4));
      table.addItem(new Object[] {
          "Johannes","Kepler",    new Integer(1571)}, new Integer(5));
      table.addItem(new Object[] {
          "Isaac",   "Newton",    new Integer(1643)}, new Integer(6));

        excelExportButton.setIcon(export);

        excelExportButton.addListener(new ClickListener() {
            private static final long serialVersionUID = -73954695086117200L;
            private ExcelExport excelExport;

            public void buttonClick(final ClickEvent event) {
                excelExport = new ExcelExport(table);
                excelExport.excludeCollapsedColumns();
                excelExport.setReportTitle("Demo Report");

                excelExport.export();
            }
        });


      vlaLayout.addComponent(table);
      vlaLayout.addComponent(excelExportButton);

setCompositionRoot(vlaLayout);

4

2 回答 2

1

我想您不再需要答案了,但我正在为那些最终在这里寻找示例的人提供链接。请在这里找到

于 2016-01-25T04:53:06.647 回答
0

这段代码在 vaadin 6 项目中对我有用,我希望仍然在 vaadin 7 上工作

   private ExcelExport excelExport;

   btnExcel.addListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (tMovement.size() > 0){

                excelExport=  new ExcelExport(tMovement,"Movimientos");
                excelExport.setReportTitle("Movimientos");
                excelExport.setDisplayTotals(false);
                excelExport.setDoubleDataFormat("0");
                excelExport.export();

            }else{
                showMessage("AVISO", ("No hay registros para exportar"),1);
            }
        }
    });
于 2016-01-26T01:26:43.043 回答