This crops up fairly regularly and the reason lies in the default bahviour of the Excel application. When you create a workbook, Excel will only store information within the file relating to cells/rows that have data in them. If no one has ever entered anything into, for example, cell D13, then a record for that cell will not exist in the file. POI will not create records for missing cell sunless you ask it to do so, and you can by using the MissingCellPolicy.
I am not at my own PC now and so cannot point you to an example but, from memory, this technique allows you to tell POI to behave in a specific way when it encoounters missing cells in a workbook. Again, from memory, it is possible, I think, to tell it to return a blank cell, an empty cell or null, and there may be others. With a bit of googling, I found this example on teh stackoverflow site Row r = sheet.getRow(2); Cell c = r.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK); and think it contains all that is relevent here. When you try to get the cell, simply specify what should happen if a cell is missing. Hope this helps. Yours Mark B -- View this message in context: http://apache-poi.1045710.n5.nabble.com/how-to-deal-with-the-empty-cells-in-poi-tp5711012p5711015.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
