views:

651

answers:

1

I dont find how to remove a column with the Apache POI API. I would appreciate a sample code or help on this point. Thank you

+1  A: 

I think you have to go down each HSSFRow and call HSSFRow.getCell and then HSSFRow.removeCell. The API is oriented towards rows, rather than columns, and very few operations work at the whole column level.

Sample code (untested):

HSSFSheet sheet = ...
int colToRemove = 5;
Iterator rowIter = sheet.iterator();
while (rowIter.hasNext()) {
   HSSFRow row = (HSSFRow)rowIter.next();
   HSSFCell cell = row.getCell(colToRemove);
   row.removeCell(cell);
}
jsight