poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Danny Mui <da...@muibros.com>
Subject Re: HSSFSheet.shiftRows() screen dump
Date Fri, 05 Sep 2003 05:25:10 GMT
I'm going to take a look at it tomorrow.  I've been quite busy at work 
(still there!).

Xuemin Guan wrote:

> Hi, Danny, I have reported it as bug22922 yesterday. I made
> two attachment to the bugzilla as well. One is a test Excel file
> another is a test program. Could you please take a look at
> bug22922? If you have any problem such as unable to re-produce
> the bug etc, please feel free to contact me.
>
> Thanks a lot,
>
> Xuemin Guan
>
> Xuemin Guan wrote:
>
>> Hi, Danny, I tried to post a but to the bugzilla, but, for
>> some reasons, the bugzilla just did not let me create an account.
>>
>> So, I have to post the test program and Excel file again.
>>
>> The test program, TestShiftMerged.java, take the users' input
>> as the begining row to shift the rows between the last row
>> and the begining row. The test Excel file contains merged cells.
>> Any attempt to shift the rows which cotains the second row
>> will cause an IndexOutBoundExcpetion. Here is a little screen dump:
>>
>> -----------------runing the TestShiftMerged-------------
>>
>> Input the row number or Q to quit please
>> 4
>> shifting rows between:3 and 13 1 row down Rows shifted.
>> Input the row number or Q to quit please:
>> 2
>> shifting rows between:1 and 14 1 row down
>> java.lang.IndexOutOfBoundsException: Index: 89, Size: 43
>>
>> --------------------------screen dump ends--------------------
>>
>> Best,
>>
>> Xuemin Guan
>>
>>
>> Danny Mui wrote:
>>
>>> Yes, I recreated as much as I could from the emails but couldn't 
>>> reproduce it.  To minimize any mixups, it's better to submit them 
>>> all in one batch to bugzilla.
>>>
>>> http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=POI
>>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> 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