Should you not have typed wks.removeRow(0);
The parameter you are passing is a reference to the row you have just created and I think that the removeRow() method requires an int. Terrence Enger <[EMAIL PROTECTED]> wrote: Greetings, all. I am very new to HSSF and almost as new to Java, so if there is something basic that I could have done to get into trouble, that is the first thing I need to know. The program ... > /* > * Add a row and delete it > * > */ > > /* imports, following the example of ReadWriteWorkbook.java, as distributed > * with the HSSF package > */ > > import org.apache.poi.poifs.filesystem.POIFSFileSystem; > import org.apache.poi.hssf.usermodel.HSSFWorkbook; > import org.apache.poi.hssf.usermodel.HSSFSheet; > import org.apache.poi.hssf.usermodel.HSSFRow; > > import java.io.FileInputStream; > import java.io.FileOutputStream; > import java.io.IOException; > > > > public class AddDltRow { > > > public static void main(String[] args) { > > // Create book, sheet, and row. > HSSFWorkbook wkb = new HSSFWorkbook(); > HSSFSheet wks = wkb.createSheet(); > HSSFRow row = wks.createRow( 0 ); > > // Delete the row > wks.removeRow ( row ); > > } // main() > > } // class AddDltRow fails with ... > Exception in thread "main" java.lang.IndexOutOfBoundsException: Row number must > be between 0 and 65535, was <-1> > at org.apache.poi.hssf.usermodel.HSSFRow.setRowNum(HSSFRow.java:206) > at org.apache.poi.hssf.usermodel.HSSFSheet.getRow(HSSFSheet.java:309) > at org.apache.poi.hssf.usermodel.HSSFSheet.findLastRow(HSSFSheet.java:243) > at org.apache.poi.hssf.usermodel.HSSFSheet.removeRow(HSSFSheet.java:217) > at AddDltRow.main(AddDltRow.java:34) I think this happens only when I remove row 0 and it is the only row in the sheet: I can delete row 0 if there is another row in the sheet, and I can delete the last row of the sheet if it is not row 0. My machine is running Windows XP and Java 1.5.0_08. The problem happens with both poi-3.0-alpha2-20060616.jar and poi-2.5.1-final-20040804.jar, although I *think* I remember seeing differences between the two versions as I was hacking around trying to create a small program to demonstrate the failure. Thank you, all, for your attention. Terry. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/ --------------------------------- Everyone is raving about the all-new Yahoo! Mail beta.