Categories

CSV/Excel Utility Package for Java

Table of Contents

What is the CSV/Excel Utility Package?

Unfortunately, Java does not offer any methods to simply read CSV files or produce such, not mentioning Excel. I for myself found it quite easy to work with such files; especially when you need to deal with data from and to Microsoft Excel.

My CSV/Excel Utility Package, published under the GNU Lesser General Public License, allows you to easily integrate CSV and Excel functionality into your application, just by using Iterator-like classes for reading, and PrintStream-like classes for writing. The CSV tools can be configured to use different column delimiter and separator characters in case you need to adopt some other versions of CSV. The default configuration conforms to the Excel style of CSV.

The Excel tools conform to the same way that CSV tools behave (see below). Therefore, two new interfaces TableReader and TableWriter were introduced to reflect the common functions. The new ExcelWriter allows you to easily create Excel files while still having the flexibility of formatting issues (see ExcelFormatter interface). The implementation is based on Apache’s POI library.

Since this CSV/Excel package uses streams, you are able to read from any stream. And, of course, you can write to any stream. You could even synchronize within your application by applying the reader/writer synchronization described in one of my articles.

Please notice that some methods are deprecated since V2.0 and CSVReader and CSVWriter classes are moved into other packages in favour of readability and structuring of the classes.

Excel functionality is available since version 2.0.

Maven Coordinates

<dependency>
   <groupId>eu.ralph-schuster</groupId>
   <artifactId>csv</artifactId>
   <version>3.0.0</version>
</dependency>

Documentation

The most extensive technical documentation is available at the Maven Site. Make sure you checked out the FAQ, too.

Change Log

A complete complete change log is available through the new Maven Site.

Current version 3.0.0 upgrades dependencies, Java compile version and some minor issues.

Download

Stable Release

The most recent stable version is V3.0.0. You can download it here. It includes the source files, the API documentation and the ready-to-use binary JAR file. You could access the GitHub repository and the API documentation. There is also a FAQ available which explains most common tasks by examples.

V3.0.0: DownloadAPI Documentation

Earlier Releases

You can download earlier releases and browse the API documentation, too:

Eclipse/Luna Plugin

This project is part of the Eclipse RCP Common Feature.

How to report a Bug or request a Change

There is a JIRA instance running at https://jira.ralph-schuster.eu/ where you can report bugs or request changes. Contributions are also welcome via JIRA.

Contributions

Many thanks to the following people for improving CSV/Excel Utility Package:

  • eldn – JUnit Testing
  • Andrej Czapszys – Handling of blank lines and calculated cells in Excel

Coverity Scan Status

34 replies on “CSV/Excel Utility Package for Java”

Very good library, especially JDBC->Excel. You should submit it to official Maven repos as you can reach much more interest with your project. The benefit is devs can include it in projects with five lines of XML dependency and updating is just matter of changing version string. Maven does all download, dependency management and storage stuff.

CSV files do not have a “second sheet”, there is only one “sheet” per CSV file. That means in order to read a second CSV file you simply create a new CSVReader.

Hope this helps….

Hi!! Great library, Good Job, I have used in one of my projects to read XLS, XSLSX and CSV, created by Excel.

But i had problems when i tried to read a CSV created by another editors like notepad and ultraedit, especially with diferents codifications.

Are there any posibility of add a charset enconding?.

Hi antuan,

yeah I saw that the charset support is not there. In V2.3, It uses the default charset by default. However, I added the support already for the 2.4 release. You can either use the SNAPSHOT version or wait for the release. I most likely will release it next week.

Ok Ralph I was going to tell you that i could add this improvement to you code but you have already done :-), when you release the new versión i will try, now i´m using you 2.3 versión.

Thanks for all.

Hello,

Great Job! I was wondering if there was a way to write in an existing Excel file without removing all information that was already in the file before? I do not know how to proceed.

Thanks,

KR,

Hi Ralph,
I would like to extend your CSV/Excel code to use memory map files. Let me know if you have already done this work, if not, also let me know if you are interested in adding my extended code.

regards,
cm

Hi Craig,

thanks for the offer. Of course, I accept it and will be happy to include it with the next release. I’ll send you an email where you can send your code to.

Ralph

netbeans complains about maven dependency. wants groupid to be groupId and artifactid to be artifactId.

Leave a Reply

Your email address will not be published. Required fields are marked *