Home » excel » java – Programatically convert complex Excel file into HTML format

java – Programatically convert complex Excel file into HTML format

Posted by: admin May 14, 2020 Leave a comment


I have a set of complex Excel files (with figures in it) that I want to show in a web browser. So I need to convert them into HTML page first. Since the excel files are very complex, I can not just parse them and generate a HTML table with HTML tags. The current manual solution that works fine is when I use Microsoft Excel software to save the spreadsheet as a HTML page. I want to automate this task in some way since I want to do it progrmatically through Java. Is their any existing solution or a way to do it? Thanks.

EDIT – I was able to create a macro for it but could not figure it out that how can I execute a macro on excel file from a Java program. Does somebody know?

How to&Answers:

If open office does a good job of the export then you could take a look at the source to see how it does it. OO is a combination of Java and C++ I believe so you might get lucky and find a Java solution.

Otherwise, I would try and use Excel itself to do the export and find some way of calling it programmatically. If you go down this path you’d be better of using a Microsoft stack (C# would be the most similar to Java) as I would expect it to have all the functions you need already defined.


You might look into POI:



I think your best bet is to call Excel from Java using JACOB

Creating direct COM calls (which is what you’ll be doing from JACOB) is a bit tough, but you’ll get the hang of it. I can’t imagine that the Excel VBA macro is horribly complicated. Take a look at the sample code (Usage and Documentation) in the JACOB link for what this will look like.

One other thing: Remember to explicitly clear references. JACOB will release COM handles when objects are garbage collected, but if you are doing any sort of high performance work, you will want to close those connections as quickly as possible. We generally write all of our COM code in a series of try/finally statements – the code is messy, but robust.


Try using hypernumbers. (Disclaimer, I’m the CEO)


I ended up using the Scribd API. I uploaded the document to their server through their API in realtime and pasted an iframe with a link in it which is returned by Scribd.