我是Vaadin的新手。这时我的ExcelExport出现了问题。
当我点击按钮时,它不下载文件以及不显示eny错误。
我不知道这个档案的位置是什么。
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);
答案 0 :(得分:1)
我想你不再需要答案,但我正在为那些最终在这里寻找例子的人提供链接。 Please find it here
答案 1 :(得分: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);
}
}
});