在ExtGWT中上传并读取excel文件

发布于 2024-11-27 09:03:08 字数 131 浏览 1 评论 0原文

我正在使用 ExtGWT。在我的应用程序中,我应该通过浏览按钮接受excel文件,并且应该读取excel文件的内容并显示在网格中。请建议我如何实现这一目标。

谢谢!

I am using ExtGWT. in my application i should accept excel file through browse button and should read the content of excel file and display in a grid. please suggest me how to achieve this.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

标点 2024-12-04 09:03:09

您必须通过 FileUploadField 上传 Excel 文档 - 请参阅:API示例

在您的服务器上,您必须读取该文件并通过外部 Excel API 解析它,例如

然后你将结果传递给你的客户端列出并将其显示在编辑器网格上。

请小心文件上传,因为文件上传方式与常规 GXT 表单不同。

正如您在示例中看到的,您需要为表单指定一个 URL

panel.setAction("myurl");  

最简单的方法是为此操作编写一个 servlet 并像 commons-fileupload

FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List<FileItem> files = upload.parseRequest(request);

// process uploaded files

遗憾的是,某些浏览器不支持通过 XMLHttpRequest 上传文件。

You will have to upload the excel document via a FileUploadField - See: API and Example

On your server you will have to read the file and parse it via an external Excel API like one of those

Then you pass the result to your client as List<ModelData> and display it on your editor grid.

Be careful about the fileupload because the file is not uploaded in the same way like your regular GXT forms.

As you can see in the example you need to specify an URL for your form

panel.setAction("myurl");  

The easiest way, would be to write a servlet for this action and process the file there like that with commons-fileupload

FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List<FileItem> files = upload.parseRequest(request);

// process uploaded files

Uploading files via XMLHttpRequest is unfortunately not supported by some browsers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文