Hello,

See subject, I already made a patch (see below) though I am sure it's just a
dirty shortcut. Any advice as to how much havok this will create for me (if
at all) would be greatly appriciated.

try{
  HSSFWorkbook workbook = new 
        HSSFWorkbook(new POIFSFileSystem(
                         new FileInputStream("sompath/test.xls")));
                        
  int countSheets = workbook.getNumberOfSheets();
  log.debug("countsheets:" + countSheets);
  HSSFSheet sheet1 = workbook.getSheetAt(1);
  int num_names = workbook.getNumberOfNames();
                        
  for(int i =0; i < num_names; i ++)
  {
        HSSFName cur_name = workbook.getNameAt(i);
        log.debug("Name:"+ cur_name.getNameName());
        log.debug("Sheet:" + cur_name.getSheetName());
                                
        log.debug("Ref:" + cur_name.getReference());
                                
  }
                        
                        
                        
}catch(Throwable t)
{
        log.fatal(t);
}

Error:
90 [main] FATAL Play  - Error:
java.lang.IndexOutOfBoundsException: Index: -2, Size: 2
        at java.util.ArrayList.RangeCheck(ArrayList.java:508)
        at java.util.ArrayList.get(ArrayList.java:320)
        at
org.apache.poi.hssf.model.Workbook.getSheetName(Workbook.java:502)
        at
org.apache.poi.hssf.model.Workbook.findSheetNameFromExternSheet(Workbook.jav
a:1756)
        at
org.apache.poi.hssf.model.Workbook.getSheetReferences(Workbook.java:1739)
        at
org.apache.poi.hssf.usermodel.HSSFName.getReference(HSSFName.java:127)
        at Play.main(Play.java:35)

My Fix:

Class: org.apache.poi.hssf.model.Workbook
Method: public String findSheetNameFromExternSheet(short num)

replaced:
[1754] short indexToSheet =
externSheet.getREFRecordAt(num).getIndexToFirstSupBook();
[1755] result = getSheetName(indexToSheet);

with 
        result = getSheetName(num);

Junit: 2 Failures (Simple.xls exists and is readable), 24
Errors(null/somefile not found, all of them)

My Setup: 1.4.1_01 JDK/ Win2k / Sp3


Thank you,
Wulf
{ ....

FileReader fr= new FileReader("Daily1.txt");
BufferedReader br = new BufferedReader(fr);
String sheetName="Daily";
String fileName ="out.xls";

FileOutputStream fileOut = new FileOutputStream(fileName);

wb = new HSSFWorkbook();
sheet = wb.createSheet(sheetName);

sheet.setGridsPrinted(false);
sheet.setPrintGridlines(false);
....
....

wb.write(fileOut);
fileOut.close();
fr.close();
}

Kindly help me find the problem.

Regards,
Arshi
g  GE Industrial Systems
 ________________________________________
 
Arshi Singh
Graduate Engineer Tr, GE-IBC
GE Industrial Systems
Center Point, HUDA Lane
Begumpet, Secunderabad 500 003
 
email:  [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  
Tel:  91-40-27881480 (D), 1800
 


"THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
ADDRESSEE and may contain confidential and privileged information.
If the reader of this message is not the intended recipient,
you are notified that any dissemination, distribution or copy of this 
communication is strictly Prohibited. 
If you have received this message by error, please notify us 
immediately, return the original mail to the sender and delete the 
message from your system."


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to