How to call a Macro from Apache POI library in Java?

Viewed 33591

I have :

  • Macro named "process" that does all the processing work for my worksheets.

  • I want my Java code that uses Apache POI, to call this macro so that it can process the sheets for me.

  • How can I call a Macro in Apache POI in Java ?

:: Note ::

  • I am using import org.apache.poi.ss.usermodel in Apache POI.

  • Please, give sample code. (I am new to Apache POI and Java itself.)

4 Answers

One little hacky way to do this is to make your macros run automatically when the workbook is opened. This can be done from vba in ThisWorkbook module. Then you can open excel with Desktop.getDesktop().open(new File(filePath)); and with apache POI and FileInputStream just get the result of 'process' .

Related