简体   繁体   English

是否可以从POI将Excel添加到Excel工作表中?

[英]Is it possible to add VB to an Excel sheet from POI?

Does anyone know if it's possible to add VB to an Excel document, from within Java? 有没有人知道是否可以从Java中将VB添加到Excel文档中? I basically want to add a pivot table to a sheet, and set some of it's properties dynamically. 我基本上想要将一个数据透视表添加到工作表,并动态设置它的一些属性。 I know that I can access the pivot table settings from VB, but not directly from POI. 我知道我可以从VB访问数据透视表设置,但不能直接从POI访问。

I've done something similar, where I've created a spreadsheet with VBA in advance using Excel. 我已经做了类似的事情,我用Excel 预先用VBA创建了一个电子表格。 I then load it using POI, populate the values and then save it out again. 然后我使用POI加载它,填充值然后再将其保存。 Thus I get a spreadsheet with the populated values and the preconfigured VB/macros etc. 因此,我得到一个包含填充值和预配置VB /宏等的电子表格。

Perhaps you need to create your VBA in advance, and it will read its dynamic properties from the sheet. 也许您需要提前创建VBA,它将从工作表中读取其动态属性。 You can then populate these properties at will. 然后,您可以随意填充这些属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM