将 POI 工作簿流式传输到 servlet 输出流 [英] Streaming a POI workbook to the servlet output stream

查看:27
本文介绍了将 POI 工作簿流式传输到 servlet 输出流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Web 服务器上构建了一个非常大的 POI 工作簿.将整个工作簿保存在内存中,不会针对多个并发请求进行扩展.有没有一种方法可以逐步将工作簿写入 servlet 输出流.这应该会减少响应时间,并提高进程内存效率.

I build a very large POI workbook, on my web server. Holding the entire workbook in memory , will not scale for multiple concurrent requests. Is there a way i can progressively write the workbook to the servlet output stream. That should reduce the response time , as well as make the process memory efficient.

推荐答案

如果您要生成 Excel 2007 (xslx),那么您可以调整 BigGridDemo.java 的方法,如下所述:http://web.archive.org/web/20110821054135/http:///www.realdevelopers.com/blog/code/excel

If you are about to generate Excel 2007 (xslx) then you could adapt the approach of BigGridDemo.java as described here: http://web.archive.org/web/20110821054135/http://www.realdevelopers.com/blog/code/excel

解决方案是让 POI 仅生成一个容器 xslx 作为模板,并将实际电子表格数据作为 XML 流式传输到 zip 输出流中.简化 XML 生成取决于您.

The solution is to let POI generate a container xslx as a template only and stream the actual spreadsheet data as XML into a zip output stream. Streamlining the XML generation is then up to you.

这篇关于将 POI 工作簿流式传输到 servlet 输出流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆