Bug 39989 - the function removeRow doesnot work
Summary: the function removeRow doesnot work
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-07 12:13 UTC by Dmitry Smirnov
Modified: 2006-08-29 07:39 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Smirnov 2006-07-07 12:13:10 UTC
hi! When I remove row there is an exception (see below)


example:
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class Test {

    public static void main(String[] args) {
        try {
            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFSheet sheet = wb.createSheet();

            for (int i = 0; i < 10; i++) {
                HSSFRow row = sheet.createRow(i);
                HSSFCell c1 = row.createCell((short) 0);
                c1.setCellValue(new HSSFRichTextString("TEST"));
                HSSFCell c2 = row.createCell((short) 1);
                c2.setCellValue(new HSSFRichTextString("TEST2"));
            }

            sheet.removeRow(sheet.getRow(5));


            FileOutputStream out = new FileOutputStream("C:\\2.xls");
            wb.write(out);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



exception:
java.lang.ArrayIndexOutOfBoundsException: 2144
	at org.apache.poi.util.LittleEndian.putNumber(LittleEndian.java:511)
	at org.apache.poi.util.LittleEndian.putShort(LittleEndian.java:244)
	at org.apache.poi.hssf.record.EOFRecord.serialize(EOFRecord.java:80)
	at org.apache.poi.hssf.model.Sheet.serialize(Sheet.java:719)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:937)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:875)
	at Test.main(Test.java:36)
Comment 1 Amol Deshmukh 2006-08-29 14:39:00 UTC
I did verify that this bug exists in 3.0-alpha2 jar.
However, this seems to be already fixed in SVN trunk.