ASF Bugzilla – Attachment 8057 Details for
Bug 22922
HSSFSheet.shiftRows() throws java.lang.IndexOutOfBoundsException:
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
The test program to reproduce the problem. Needs to work together with the previously attached MS-Excel file.
TestShiftMerged.java (text/plain), 2.34 KB, created by
Xuemin Guan
on 2003-09-04 02:10:16 UTC
(
hide
)
Description:
The test program to reproduce the problem. Needs to work together with the previously attached MS-Excel file.
Filename:
MIME Type:
Creator:
Xuemin Guan
Created:
2003-09-04 02:10:16 UTC
Size:
2.34 KB
patch
obsolete
> >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(); > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 22922
:
8056
| 8057