是否可以将VB添加到POI的Excel表中?

时间:2022-10-09 20:25:24

Does anyone know if it's possible to add VB to an Excel document, from within Java? 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.

有没有人知道可以从Java将VB添加到Excel文档中?我基本上想向一个表添加一个pivot表,并动态地设置它的一些属性。我知道我可以从VB访问pivot表设置,但不能直接从POI访问。

1 个解决方案

#1


7  

I've done something similar, where I've created a spreadsheet with VBA in advance using Excel. I then load it using POI, populate the values and then save it out again. Thus I get a spreadsheet with the populated values and the preconfigured VB/macros etc.

我也做过类似的事情,我使用Excel预先用VBA创建了一个电子表格。然后我使用POI加载它,填充值,然后再次保存。这样我就得到了一个包含填充值和预配置VB/宏等的电子表格。

Perhaps you need to create your VBA in advance, and it will read its dynamic properties from the sheet. You can then populate these properties at will.

也许您需要预先创建VBA,它将从表中读取它的动态属性。然后可以随意填充这些属性。

#1


7  

I've done something similar, where I've created a spreadsheet with VBA in advance using Excel. I then load it using POI, populate the values and then save it out again. Thus I get a spreadsheet with the populated values and the preconfigured VB/macros etc.

我也做过类似的事情,我使用Excel预先用VBA创建了一个电子表格。然后我使用POI加载它,填充值,然后再次保存。这样我就得到了一个包含填充值和预配置VB/宏等的电子表格。

Perhaps you need to create your VBA in advance, and it will read its dynamic properties from the sheet. You can then populate these properties at will.

也许您需要预先创建VBA,它将从表中读取它的动态属性。然后可以随意填充这些属性。