Writing to a particular cell location using Apache POI Excel

If I've got an list of parameters 'x,y,z' that aren't sorted, is there a straightforward way to write them to particular cells in an excel document created with POI, as though the first two parameters are X and Y coordinates?

For example, I have rows like:


Is it possible to write the value '100' in the cell at the 10th row, 4th column?

Looking at the documentation, it looks straightforward to iterate values into the next row, but I can't see any way of creating a fixed number of rows and columns and writing particular values to only certain cells.

Any advice or suggestions would be appreciated, thanks!


Sure, it's very easy, just remember that POI is 0 based not 1 based in addressing. Assuming you want to write to the 10th row, 4th column, you'd do something like

Row r = sheet.getRow(9); // 10-1
if (r == null) {
   // First cell in the row, create
   r = sheet.createRow(9);

Cell c = r.getCell(3); // 4-1
if (c == null) {
    // New cell
    c = r.createCell(3, Cell.CELL_TYPE_NUMERIC);

Need Your Help

How to only return an array from this class?

php curl

I'm a preocedural programmer, and dont know much about objects.

How to turn a single-site app into a mantainable multi-site app without code changes?

ruby-on-rails ruby database-design web-applications

It's an application that we use internally at the office that I would like to offer as a hosted service for anyone.