aspose file tools*
The moose likes Other Open Source Projects and the fly likes Delete a row from an Excel sheet with Apache POI / HSSF? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Delete a row from an Excel sheet with Apache POI / HSSF?" Watch "Delete a row from an Excel sheet with Apache POI / HSSF?" New topic
Author

Delete a row from an Excel sheet with Apache POI / HSSF?

Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Anyone know how I can remove a row from an Excl sheet using Apache POI / HSSF? I tried the HSSFSheet.removeRow() method, but that seems to only clear the contents of the row, not remove it from the sheet.

Arun Kumar
Ranch Hand

Joined: Oct 10, 2007
Posts: 30
removeRow takes org.apache.poi.ss.usermodel.Row object. Incase you are passing the right Row object, it does delete the Row. Other option is to create a new sheet excluding that row.
Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Arun Kumar wrote:removeRow takes org.apache.poi.ss.usermodel.Row object. Incase you are passing the right Row object, it does delete the Row. Other option is to create a new sheet excluding that row.


Thanks Arun. Maybe this is something specific to the particular Excel file I'm trying to use (although I have tried it on many files), or the way I iterate over the rows in the sheet, but the row is never deleted, only cleared.

Basically, I'm trying to go through the sheet, row by row, remove specific rows that don't meet certain criteria, then save the sheet under a new filename. Here's the code:



If anyone has tried this before, and succeeded, can you let me know how you did it?

thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Delete a row from an Excel sheet with Apache POI / HSSF?
 
Similar Threads
Apache POI
Detect filter in excel sheet using Apache POI
how to fetch data from excel sheet and dump to Mysql database
java.lang.OutOfMemoryError using Apache POI.jar
regarding POI HSSF programming