gpt4 book ai didi

java - 在 Vaadin 中显示电子表格组件

转载 作者:行者123 更新时间:2023-12-01 17:46:13 26 4
gpt4 key购买 nike

我正在使用 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 帮助程序类:

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.

关于java - 在 Vaadin 中显示电子表格组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55077389/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com