poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xuemin Guan <xue...@appresso.com>
Subject Re: HSSFSheet.shiftRows() screen dump
Date Tue, 02 Sep 2003 07:23:16 GMT
Sorry, forgot the screen dump:

------------------screen dump begins----------------------
poi.execute:
      [java] Input the row number or Q to quit please:
3
      [java] shifting rows between:2 and 11 1 row down
      [java] Rows shifted.
      [java] Input the row number or Q to quit please:
3
      [java] shifting rows between:2 and 12 1 row down
      [java] Rows shifted.
      [java] Input the row number or Q to quit please:
1
      [java] shifting rows between:0 and 13 1 row down
      [java] java.lang.IndexOutOfBoundsException: Index: 87, Size: 43

----------------screen dump ends-------------------------------

For the dump, we can see that the problem arises when
attempting to shift the rows between first row(with POI, it
is the No. zero row.) and the 13th row.

Regards,

Xuemin

Xuemin Guan wrote:
> Hi, Danny, really grateful for your help.
> 
> I don't know why you could not re-produce the same problem.
> I am using pre3:
> 
> poi-scratchpad-2.0-pre3-20030728.jar;
> poi-contrib-2.0-pre3-20030728.jar;
> poi-2.0-pre3-20030728.jar;
> 
> Are you using the very fresh copy from the CVS? I did
> try the CVS, but the code did not compile, so I gave it
> up. And tested again with the above 3 jars files. I could
> re-produce the problmes every time I run the test program.
> 
> I have attached the test program and the Excel file for
> testing. The following the the screen dump from the test
> program. Should you have any question, please feel free
> to contact me.
> 
> Thanks a lot!
> 
> Xuemin
> 
> 
> 
> Danny Mui wrote:
> 
>> Hi Xuemin,
>>
>> I just checked-out pre3 and ran the test you indicated for BOTH of the 
>> files you provided.  I did not get the error.  Also, the code doesn't 
>> look too fishy since we're doing a bounds check before we remove it.  
>> What Operating System and JVM are you using?
>>
>> Please make sure you're using pre3 code.
>>
>> danny
>>
> 
> ------------------------------------------------------------------------
> 
> 
> import org.apache.poi.poifs.filesystem.POIFSFileSystem;
> import org.apache.poi.hssf.usermodel.HSSFWorkbook;
> import org.apache.poi.hssf.usermodel.HSSFSheet;
> 
> import java.io.*;
> 
> /**
>  * Author: Xuemin Guan <xuemin@appresso.com>
>  * Date: 2003/09/02
>  * Time: 12:05:59
>  */
> public class TestShiftMerged {
>     public static void main(String[] args) throws Exception {
> 		//Read in the excel file and build the workbook.
>         InputStream istream = new FileInputStream("shiftmerged.xls");
>         POIFSFileSystem fs = new POIFSFileSystem(new BufferedInputStream(istream));
>         HSSFWorkbook workbook = new HSSFWorkbook(fs);
>         istream.close();
>         HSSFSheet sheet = workbook.getSheetAt(0);
>         BufferedReader screenIn = new BufferedReader(new InputStreamReader(System.in));
>         int rowNum = 0;
>         while (true) {
> 			//obtain the last row number.
>             int lastRowNum = sheet.getLastRowNum();
>             //for loop: get input from the users. the users can specify which
>             //row is the first row to be shifted.
>             for (; ;) {
>                 System.out.println("Input the row number or Q to quit please:");
>                 String line = screenIn.readLine();
>                 try {
>                     if (line.equalsIgnoreCase("q")) {
>                         System.out.println("Program terminated. Quiting...");
>                         System.exit(0);
>                     } else {
>                         rowNum = Integer.parseInt(line);
>                         if (rowNum >= lastRowNum) {
>                             System.out.println("Must be less than the last row number.");
>                             continue;
>                         }
>                     }
>                     if (rowNum > 0)
>                         rowNum--;
>                     break;
>                 } catch (NumberFormatException e) {
>                     continue;
>                 }
>             }
>             System.out.println("shifting rows between:" + rowNum + " and " + lastRowNum
+ " 1 row down");
>             sheet.shiftRows(rowNum, lastRowNum, 1, true, true);
>             System.out.println("Rows shifted.");
>             FileOutputStream fileOut = new FileOutputStream(new File("shiftmerged.xls"));
>             workbook.write(fileOut);
>             fileOut.flush();
>             fileOut.close();
>         }
>     }
> }
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


Mime
View raw message