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

   <groupid>eu.ralph-schuster</groupid>
   <artifactid>csv</artifactid>
   <version>2.7.0</version>

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 2.7.0 improves performance.

Download

Stable Release

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

V2.7.0: DownloadAPI Documentation

Nightly Build

Nightly builds have been abandoned since Maven migration. You can find the latest Snapshot at Sonatype’s repository.

Earlier Releases

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

How to report a Bug or request a Change

There is a JIRA instance running at http://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

30 Responses to “CSV/Excel Utility Package for Java”

  1. Ralph’s TechBlog » Blog Archive » CSV Utility Package V1.0.1 released Says:

    [...] new update of my CSV Utility Package was released. It contains some fixes and [...]

  2. Ralph’s TechBlog » Blog Archive » CSV Utility Package V1.0.2 released Says:

    [...] I made some fixes and enhancements to the CSV Utility Package: [...]

  3. Ralph’s TechBlog » Blog Archive » CSV Utility Package 2.0 Beta Says:

    [...] work has been spent over the last weeks to upgrade the stable CSV Utility Package. Of course, the new version contains all the useful existing functionality. The most benefitial [...]

  4. Audio Services Jobs Says:

    Hey…..nice post!!

    Awesome, No more words to explain :) :) :D just….cool blog.

  5. Ralph’s TechBlog » Blog Archive » CSV/Excel Utility Package V2.0.1 released Says:

    [...] can download it here or visit the Homepage of the utility where you will find some examples on how to use [...]

  6. Insolvenční Rejstřík Says:

    May I mavenize your lib and publish it somewhere?

  7. Ralph Says:

    Hey,

    of course. Just make sure you follow the LGPL license (naming your source)

  8. Insolvenční Rejstřík Says:

    Hi, done, see http://ondrazizka.googlecode.com/svn/maven/cz/dynawest/third/csv/csv/2.0.1/

  9. Insolvenční Rejstřík Says:

    Regarding LGPL – Maven way of referencing the source is adding project’s URL to the POM, which is then used for eventual reports and generated site. Is that OK?

    By the way, I created a related tool, see here:
    http://ondra.zizka.cz/stranky/programovani/ruzne/querying-transforming-csv-using-sql.texy

  10. Ralph’s TechBlog » Blog Archive » CSV/Excel Utility Package V2.2 released Says:

    [...] can download the new version here or visit the Homepage of the utility where you will find some examples on how to use [...]

  11. mrp Says:

    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.

  12. hidayath Says:

    How can i read a second sheet in csv file.

  13. Ralph Says:

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

  14. Ralph’s TechBlog » Blog Archive » CSV/Excel Utility Package V2.1 released Says:

    [...] can download the new version here or visit the Homepage of the utility where you will find some examples on how to use [...]

  15. Ralph’s TechBlog » Blog Archive » CSV, B4J and Templating become integrated with Maven Says:

    [...] so they can be more easily integrated with other projects. Now it’s coming around the corner. CSV/Excel Utility Package is almost complete and you can already see the results in the Nightly Build. The release is not far [...]

  16. Ralph’s TechBlog » Blog Archive » CSV/Excel Utility Package 2.3 released Says:

    [...] can download the new version here or visit the Homepage of the utility where you will find some examples on how to use [...]

  17. antuansoft Says:

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

  18. Ralph Says:

    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.

  19. antuansoft Says:

    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.

  20. Ralph Says:

    Hi Antuan,

    version 2.4.0 has just been releases. The charset feature is described here.

    Thanks for improving the library!

  21. Ralph’s TechBlog » Blog Archive » CSV/Excel Utility Package 2.4.0 released Says:

    [...] can download the new version here or visit the Homepage of the utility where you will find some examples on how to use [...]

  22. David Says:

    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,

  23. Ralph Says:

    Hi David!

    See the FAQ

  24. Akram Says:

    Why dont you try Fillo? It is a freeware product and used to query Excel files (xls & xlsx). Now, it supports SELECT and UPDATE queries with or without WHERE clause.

    http://www.codoid.com/products/view/2/29

  25. craigwmiller@yahoo.com Says:

    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

  26. Ralph Says:

    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

  27. Ralph’s TechBlog » Blog Archive » CSV/Excel Utility Package 2.5.0 released Says:

    [...] can download the new version here or visit the Homepage of the utility where you will find some examples on how to use [...]

  28. Ralph’s TechBlog » Blog Archive » CSV/Excel Utility Package V2.6.1 released Says:

    […] can download the new version here or visit the Homepage of the utility where you will find some examples on how to use […]

  29. Ralph’s TechBlog » Blog Archive » Short notice Says:

    […] via Sonatype to benefit from the UTF-8 encoding fix, the Jira session support and integration with CSV/Excel Utility. The Maven coordinates […]

  30. Ralph’s TechBlog » Blog Archive » CSV/Excel Utility improves performance Says:

    […] remember where). To my surprise, someone tested multiple Open Source products including my own CSV/Excel Utility Package. And even more surprising to me, mine was the worst. By far! It took 4 times as much than others […]

Leave a Reply