ASF Bugzilla – Attachment 10793 Details for
Bug 27548
getting InvocationTargetException while reading Password Protected Excel File
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
A simple test java file that shows the error
xlstest.java (text/plain), 1.80 KB, created by
Lance Wentz
on 2004-03-15 19:35:44 UTC
(
hide
)
Description:
A simple test java file that shows the error
Filename:
MIME Type:
Creator:
Lance Wentz
Created:
2004-03-15 19:35:44 UTC
Size:
1.80 KB
patch
obsolete
>import java.io.*; > >import org.apache.poi.hssf.usermodel.*; >import org.apache.poi.poifs.filesystem.POIFSFileSystem; > >/* > * Created on Mar 15, 2004 > * > */ > >/** > * @author Lance Wentz > * > */ >public class xlstest { > > /** > * > */ > public xlstest() { > > } > > public static String getText(InputStream in) throws Exception { > String text = " "; > StringBuffer x = new StringBuffer(); > POIFSFileSystem fs = new POIFSFileSystem(in); > HSSFWorkbook wb = new HSSFWorkbook(fs); > > for (int k = 0; k < wb.getNumberOfSheets(); k++) { > HSSFSheet sheet = wb.getSheetAt(k); > int rows = sheet.getPhysicalNumberOfRows(); > > for (int r = 0; r < rows; r++) { > HSSFRow row = sheet.getRow(r); > if (row != null) { > int cells = row.getPhysicalNumberOfCells(); > > for (int c = 0; c < cells; c++) { > HSSFCell cell = row.getCell((short) c); > if (cell != null) { > switch (cell.getCellType()) { > /* > * case HSSFCell.CELL_TYPE_NUMERIC : > * text+= " "+cell.getNumericCellValue(); > * break; > */ > case HSSFCell.CELL_TYPE_STRING : > try { > //text += " " + cell.getStringCellValue(); > String cv = cell.getStringCellValue(); > if (cv != null) { > cv = cv.trim(); > if (!cv.equals("")) { > x.append(" " + cv); > } > } > } catch (Exception e) { > // skip cell > } > break; > default : > } > } > } > } > } > } > if (x.length() > 0) { > text = x.toString(); > //System.out.println(text); > } > return (text); > } > > public static void main(String[] args) { > try { > System.out.println(getText(new FileInputStream(args[0]))); > } catch (Exception e) { > e.printStackTrace(); > } > } >}
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 27548
:
10729
| 10793 |
11074
|
11311