Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to export data from Java to MS Excel [closed]

Tags:

java

excel

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.

like image 390
Akinwale Agbaje Avatar asked Apr 17 '12 07:04

Akinwale Agbaje


People also ask

Can you automate Excel with Java?

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.

Can you use Java to code in Excel?

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.

What is the difference between HSSFWorkbook and XSSFWorkbook?

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 .

How to export Excel files in Java without MS Excel?

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.

How do I export data from JSON to xlsx?

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?

How to export an ArrayList to excel in Java?

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.

How to export data to excel?

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 ...


2 Answers

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

like image 90
sayannayas Avatar answered Oct 11 '22 10:10

sayannayas


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.

like image 23
zeb Avatar answered Oct 11 '22 10:10

zeb