Take 60 minutes to understand the Power of the Actor Model with "Designing Reactive Systems: The Role Of Actors In Distributed Architecture". Brought to you in partnership with Lightbend.

In part 1, we examined how to create an Excel spreadsheet and add data to it. We also looked at properly storing data into cells to avoid “Number Stored as Text” errors.

In this chapter, let us look at some more options for formatting data within an Excel spreadsheet.

Convert CSV to Excel

Let's see how we can convert CSV to an Excel spreadsheet. Excel offers this functionality with the Data Import Wizard when you attempt to import a CSV or text file. Here, we show you how to use Apache POI to parse CSVs and output an Excel Spreadsheet.

Text Wrapping

There is an option to enable text wrap using the cell style. It is enabled as follows:

CellStyle wrap = wb.createCellStyle();
wrap.setWrapText(true);

With this style set on a cell, Excel may not actually display cell data on multiple lines. This could be because the row height is set to a specific height preventing the display of multiple lines.

To set the row height to display multiple lines, do the following in Excel. (From here.)

On the Home tab, select Format in the Cells group.

Under Cell Size, select AutoFit Row Height. Now you can see the text has been wrapped and is visible.

Summary

In this article, we looked at some more options for formatting an Excel spreadsheet using Apache POI. We covered converting CSV data to Excel, Adding sort headers to columns and date formatting. In addition, cell styles can be used to set up alignment and text wrap options.

Learn how the Actor model provides a simple but powerful way to design and implement reactive applications that can distribute work across clusters of cores and servers. Brought to you in partnership with Lightbend.