I was searching the internet for an answer to exporting data from my Java desktop app to Excel and I came across the Apache POI API. Then I found out that the JDBC would work, and then I stumbled on JExcel. Are they all equally good, or should I focus on the best among them, and which is it?
Cheers.
Especially when working with loads of data, Excel makes it pretty easy to order, filter, calculate, visualize and report. Expanding into loads^2 of data and adding automation on top is also relatively simple: just couple Excel with Java to do the hard work of mining databases and delivering clean sheets.
But Java isn't part of Excel! That's true, but Excel has a concept of “add-ins” that allow developers to extend Excel's functionality. One such add-in is Jinx, the Excel Java Add-In. Using Jinx, you can completely do away with VBA and write worksheet functions, macros and menus entirely in Java.
HSSFWorkbook − This class has methods to read and write Microsoft Excel files in . xls format. It is compatible with MS-Office versions 97-2003. XSSFWorkbook − This class has methods to read and write Microsoft Excel and OpenOffice xml files in .
EasyXLS Excel library can be used to export Excel files in Java. The library works with any Java SE application and without MS Excel installed. If you already own a license key, you may login and download EasyXLS from your account.
You can easily export data from Arrays, Collection of Objects, JSON, and CSV to an XLSX file using easy-to-integrate Aspose.Cells for Java API in your Java application. How do I export data from JSON to Excel?
The following code sample shows how to export an ArrayList to Excel in Java. // Exporting the contents of ArrayList vertically at the first row and first column of the worksheet. The importArrayList () method of the Cells class exports an ArrayList of data to a worksheet. It takes four parameters including the ArrayList of data.
In order to export data to Excel perform the following steps: 1 Open the Reports whose data you are willing to export. 2 At the top right corner, you will see this type of Excel export icon. So, tap on it. More ...
I might be late to answer this, but I guess your correct choice would be Jxls. I faced a similar scenario in my module where I had to retain a certain template like logo,color,col-span,fixed column... So that's very hectic to write a separate java code and design it.
Jxls core is poi and syntactically similar to jstl, all you need is to map a array-list of bean with desired column in excel
Why so complicated?
Just TAB separate your columns and write the output to plain text file with an ".xls" extension?
That way, all you need to do is open the generated ".xls" file. Even though it's actually just a TAB-separated text file, Excel will open it and automatically treat each tab as a new column.
No idea why people still use csv files, frankly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With