Alex Rivera | Logout

Create Excel file in Java

Asked 2009-07-24T06:40:45.403
54

I want to create an Excel file and write data just like writing a text file with Java. I tried to change file extension from .txt to .xls. But I want to bold letters in the Excel file. How can I do that?

I have tried using the JXL API, but every time I have to create a label I want add no label. Can't O edit row and column of the table?

Edit
Report

2 Answers

31

You can use Apache POI for creating native binary xls files.

Or you can use JExcelApi which is another, and somewhat light-weight as far as I can remember, Java library for Excel.

answered 2009-07-24T06:42:38.083
11

Fair warning about Apache POI's Excel generation... (I know this is an old post, but it's important in case someone looks this up again like I just did)

It had a memory leak issue, which supposedly was solved by 2006, but which people quite recently have still been experiencing. If you want to automate generating a large amount of excel (i.e., if you want to generate a single, large file, a large number of small files, or both), I'd recommend using a different API. Either that, or increasing the JVM stack size to preposterous proportions, and maybe looking into interning strings if you know you won't actually be working with many different strings (although, of course, interning strings means that if you have a large number of different strings, you'll have an entirely different program-crashing memory problem. So, consider that before you go that route).

answered 2012-06-22T15:51:58.607

Your Answer