简体   繁体   English

使用Java将宏添加到Excel电子表格中

[英]Adding a macro to an Excel spreadsheet with Java

I'm developping an app that creates an Excel spreadsheet. 我正在开发一个创建Excel电子表格的应用程序。 I'm using Java with docx4j library, but it does not have Macro support since it is not provided through Open XML API. 我正在将Java与docx4j库一起使用,但它没有Macro支持,因为它不是通过Open XML API提供的。 I was just wondering if anyone knew of a workaround to add a macro to an existing Excel spreadsheet using Java (even with another library). 我只是想知道是否有人知道使用Java将宏添加到现有Excel电子表格的解决方法(即使使用其他库)。

Thanks 谢谢

If it's the same macro in all Workbooks you might be able to use a template? 如果它是所有工作簿中的相同宏,您可以使用模板? Meaning you have an empty workbook which contains the generalized makro and this will be copied for each "new" Workbook your need to create from Java. 这意味着你有一个包含通用makro的空工作簿,这将被复制为你需要从Java创建的每个“新”工作簿。

I don't think you'll find anything java-based that will be able to do this for you. 我不认为你会发现任何基于java的东西能够为你做到这一点。 However I guess native MS technologies (.NET, c# etc) will be able to do this. 但是,我猜本机MS技术(.NET,c#等)将能够做到这一点。 Although (AFAIK) you can't actually execute c# in the JVM, you can make system calls from java to execute another program using Runtime.exec() . 虽然(AFAIK)您无法在JVM中实际执行c#,但您可以使用Runtime.exec()从java进行系统调用以执行另一个程序。

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

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