在 Vaadin 中显示电子表格组件
Show Spreadsheet component in Vaadin
我正在使用 Vaadin 10,我想向用户显示一个电子表格。但是,下面的方法给我一个错误:
public class SomeUI extends VerticalLayout{
private SomeUI(){
// ... some add(Components)
String path = "C:\Users\MY_USERNAME\Desktop";
Spreadsheet sp = ExcelOpener.openFile(path);
// this line does not work
// add(sp);
}
}
下面是 ExcelOpener 助手 class:
public class ExcelOpener {
public static Spreadsheet openFile(String path){
// I will use the path to open given excel later.
// Right now I want to open an empty spreadsheet and show it to the user
Spreadsheet spreadsheet = null;
spreadsheet = new Spreadsheet();
return spreadsheet;
}
}
我的问题是:
- 如何解决 add(sp) 方法的错误:
Cannot resolve method 'add(com.vaadin.addon.spreadsheet.Spreadsheet)'
- 如何使用给定路径打开 excel?我写的路径是否正确?或者应该是
"C:/Users/MY_USERNAME/Desktop"
电子表格组件与 Vaadin 10+ 不兼容(仅 Vaadin7/8)。
正如您在此处的评论中看到的那样 https://vaadin.com/blog/vaadin-s-frontend-direction 据说:
Last part is Spreadsheet, and that one is a bit tricky. It is built on
top of POI directly, and most of the logic happens on the server side,
so it can't really work as a stand-alone client-side web component
without a major shift in architecture. We don't have plans today to
make it into a web component, but we have a couple promising avenues
that we are looking into which could bring it to Flow. First one is
that we are looking into a migration tool, or wrapper, from 8 to 10.
It basically embeds a Vaadin 8 app within a Vaadin 10 app. We have a
proof of concept with Spreadsheet for FW8 wrapped alone and embedded
within a full Vaadin 10 app. The other option is a proof of concept of
taking a compiled Vaadin 8 GWT widget and building a web component
around that, found here: https://github.com/Legioth/connector-element.
In it's essence, it replaces the server-side counterpart of Vaadin 8
and hooks itself up to the connector of the widget. This could enable
us to compile the Spreadsheet widget into an web component, migrate
the server side of Spreadsheet to Flow, and connect the server side
back to the web component. We do not, however, any concrete plans on
if we are going to do this.
我正在使用 Vaadin 10,我想向用户显示一个电子表格。但是,下面的方法给我一个错误:
public class SomeUI extends VerticalLayout{
private SomeUI(){
// ... some add(Components)
String path = "C:\Users\MY_USERNAME\Desktop";
Spreadsheet sp = ExcelOpener.openFile(path);
// this line does not work
// add(sp);
}
}
下面是 ExcelOpener 助手 class:
public class ExcelOpener {
public static Spreadsheet openFile(String path){
// I will use the path to open given excel later.
// Right now I want to open an empty spreadsheet and show it to the user
Spreadsheet spreadsheet = null;
spreadsheet = new Spreadsheet();
return spreadsheet;
}
}
我的问题是:
- 如何解决 add(sp) 方法的错误:
Cannot resolve method 'add(com.vaadin.addon.spreadsheet.Spreadsheet)'
- 如何使用给定路径打开 excel?我写的路径是否正确?或者应该是
"C:/Users/MY_USERNAME/Desktop"
电子表格组件与 Vaadin 10+ 不兼容(仅 Vaadin7/8)。
正如您在此处的评论中看到的那样 https://vaadin.com/blog/vaadin-s-frontend-direction 据说:
Last part is Spreadsheet, and that one is a bit tricky. It is built on top of POI directly, and most of the logic happens on the server side, so it can't really work as a stand-alone client-side web component without a major shift in architecture. We don't have plans today to make it into a web component, but we have a couple promising avenues that we are looking into which could bring it to Flow. First one is that we are looking into a migration tool, or wrapper, from 8 to 10. It basically embeds a Vaadin 8 app within a Vaadin 10 app. We have a proof of concept with Spreadsheet for FW8 wrapped alone and embedded within a full Vaadin 10 app. The other option is a proof of concept of taking a compiled Vaadin 8 GWT widget and building a web component around that, found here: https://github.com/Legioth/connector-element. In it's essence, it replaces the server-side counterpart of Vaadin 8 and hooks itself up to the connector of the widget. This could enable us to compile the Spreadsheet widget into an web component, migrate the server side of Spreadsheet to Flow, and connect the server side back to the web component. We do not, however, any concrete plans on if we are going to do this.