使用Excel模板与Apache POI [英] Using Excel templates with Apache POI

查看:157
本文介绍了使用Excel模板与Apache POI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本的问题:如何加载Excel模板与POI使用,然后将其保存到一个XLS文件

Basic question: How do I load an Excel template for use with POI and then save it to an XLS file?

编辑:

答案是:

FileInputStream inputStream = new FileInputStream(new File(templateFile));
Workbook workbook = new HSSFWorkbook(inputStream);

(只加载模板作为一个工作簿,然后写工作簿作为其他地方的XLS文件。)

(Just load the template as a workbook and then write the workbook as an XLS file elsewhere.)

推荐答案

您是否尝试过使用POI加载它作为一个标准的.xls,修改它,然后将其保存?

Have you tried loading it up as a standard .xls using POI, amending it and then saving it ?

这是我用于在POI生成的.xls插入宏的办法。我创建宏(当然为.xls)的文件,然后将其加载到我的应用程序,填充数据并保存为一个新创建的.xls。这一切都工作得很好。

This is the approach I've used for inserting macros in a POI-generated .xls. I create the file with the macro (admittedly as an .xls) and then load it into my app, populate with data and save as a newly-created .xls. That all worked fine.

这篇关于使用Excel模板与Apache POI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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