ASF Bugzilla – Attachment 7768 Details for
Bug 21305
Excel crashing when reading large files generated by POI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
POITest.java
POITest.java (text/plain), 1.99 KB, created by
Gerhard Ruckriegel
on 2003-08-12 09:42:35 UTC
(
hide
)
Description:
POITest.java
Filename:
MIME Type:
Creator:
Gerhard Ruckriegel
Created:
2003-08-12 09:42:35 UTC
Size:
1.99 KB
patch
obsolete
>import java.io.*; >import org.apache.poi.hssf.usermodel.*; >import java.util.*; > >public class POITest >{ > static Random random=null; > > public POITest() > { > try{ > random = new Random(26); > > HSSFWorkbook workBook = new HSSFWorkbook(); > HSSFSheet sheet = workBook.createSheet(); > > fillRange(sheet,0,9,0,820,"0123456789"); >// fillRange(sheet,0,9,0,820,"XXXXXXXXXXXXXXXX"); >// with 820 it's loadable, not dependent on string length > > String fileName = "C:\\test.xls"; > FileOutputStream outStream = new FileOutputStream(fileName); > workBook.write(outStream); > outStream.close(); > } > catch(Exception e) > { > e.printStackTrace(System.out); > } > } > > private void fillRange(HSSFSheet destination,int beginCol,int endCol,int startRow,int endRow,String value) > { > for(int rowIndex=startRow;rowIndex<=endRow;rowIndex++) > { > for(int cellIndex=beginCol;cellIndex<=endCol;cellIndex++) > { > StringBuffer returnValue= new StringBuffer(value.length()); > char character = 0; > > for(int i=0;i<value.length();i++) > { > character = (char)(random.nextInt(26)+'A'); > returnValue.append(character); > } > POITest.setCell(destination,rowIndex,cellIndex,returnValue.toString()); > } > } > } > > public static void setCell(HSSFSheet sheet, int rowNum, int colNum, String value) > { > HSSFRow row = sheet.getRow((short)rowNum); > if(row == null) > { > row = sheet.createRow((short)rowNum); > } > > HSSFCell cell = row.getCell((short)colNum); > if(cell == null) > { > cell = row.createCell((short)colNum); > } > > cell.setCellValue(value); > } > > public static void main(String[] args) > { > new POITest(); > } >}
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 21305
:
7079
| 7768 |
7769
|
7801