Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a macro to an Excel spreadsheet with Java

Tags:

java

excel

I'm developping an app that creates an Excel spreadsheet. I'm using Java with docx4j library, but it does not have Macro support since it is not provided through 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).

Thanks

like image 570
3rgo Avatar asked May 06 '11 12:05

3rgo


2 Answers

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.

like image 138
pintxo Avatar answered Oct 21 '22 02:10

pintxo


I don't think you'll find anything java-based that will be able to do this for you. However I guess native MS technologies (.NET, c# etc) will be able to do this. 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().

like image 36
Richard H Avatar answered Oct 21 '22 00:10

Richard H