Could not load the excel sheet

Hi,


I am trying to load a spreadsheet using aspose cells (for java) using the following code:

FileInputStream fileInputStream = new FileInputStream(“testFile.xlsx”);
Workbook workbook = new Workbook(fileInputStream);
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);
//Closing the file stream to free all resources
fileInputStream.close();


But the above code is giving an exception
Exception in thread “main” java.lang.IllegalArgumentException: Index is out of range.
at com.aspose.cells.Workbook.changePalette(Unknown Source)
at com.aspose.cells.zajw.m(Unknown Source)
at com.aspose.cells.zajw.n(Unknown Source)
at com.aspose.cells.zajw.a(Unknown Source)
at com.aspose.cells.zakb.r(Unknown Source)
at com.aspose.cells.zakb.a(Unknown Source)
at com.aspose.cells.zaka.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)


I have attached the spreadsheet with this post. Can someone help me regarding this.

Thank you
Muthu

The aspose cells version used is aspose-cells-8.6.2

Java : Java SE 7 [1.7.0_72]
OS: Mac OSX Yosemite 10.10

Hi,

Thanks for your posting and using Aspose.Cells.

We have tested this issue with the following sample code using the latest version: Aspose.Cells for Java (Latest Version). It loads your excel file and generates the exception as you mentioned.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-41630 - Could not load the excel sheet

I have also shown the exception for a reference.

Java
String filePath = “F:\Shak-Data-RW\Downloads\testFile.xlsx”;

Workbook workbook = new Workbook(filePath);

Exception:
Exception in thread “main” java.lang.IllegalArgumentException: Index is out of range.
at com.aspose.cells.Workbook.changePalette(Unknown Source)
at com.aspose.cells.zajw.m(Unknown Source)
at com.aspose.cells.zajw.n(Unknown Source)
at com.aspose.cells.zajw.a(Unknown Source)
at com.aspose.cells.zakb.s(Unknown Source)
at com.aspose.cells.zakb.a(Unknown Source)
at com.aspose.cells.zaka.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)
at clsAsposeCells.f1(clsAsposeCells.java:28)
at clsAsposeCells.main(clsAsposeCells.java:11)

Hi,

Thanks for using Aspose.Cells.

It is to inform you that we have fixed your issue CELLSJAVA-41630 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

The issues you have found earlier (filed as CELLSJAVA-41630) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi,

I tried with 8.6.3 version. Now it is not throwing the exception. But it is not reading anything from the excel sheet.

My code fragment is below.
FileInputStream fileInputStream = new FileInputStream(“testFile.xlsx”);
Workbook workbook = new Workbook(fileInputStream);
WorksheetCollection worksSheets = workbook.getWorksheets();
int count = worksSheets.getCount();
for(int i =0; i < count; i++) {
Worksheet ws = worksSheets.get(i);
Cells cells = ws.getCells();
int rowCount = cells.getMaxDataRow();
int colCount = cells.getMaxDataColumn();
for(int j = 0; j <= rowCount; j++) {
for(int k = 0; k <= colCount; k++) {
Cell cell = cells.get(j, k);
System.out.println(cell);
}
}
}


Hi,


Thanks for providing further details and sample code.

After an initial test, I observed the issue as you mentioned. I found that although Aspose.Cells loads the file fine but Aspose.Cells is not reading anything from the Excel sheet (first - the only sheet) in the template file. I used the following sample code with your template file:
e.g
Sample code:

FileInputStream fileInputStream = new FileInputStream(“f:\files\testfile.xlsx”);
Workbook workbook = new Workbook(fileInputStream);
WorksheetCollection worksSheets = workbook.getWorksheets();
int count = worksSheets.getCount();
for(int i=0; i < count; i++) {
Worksheet ws = worksSheets.get(i);
Cells cells = ws.getCells();
int rowCount = cells.getMaxDataRow();
int colCount = cells.getMaxDataColumn();
System.out.println("MaxDataRow: " + rowCount);//-1
System.out.println("MaxDataColumn: " + colCount);//-1
System.out.println("A1: " + cells.get(0,0).getStringValue()); //Null
System.out.println("MaxDataColumn: " + colCount);
for(int j = 0; j <= rowCount; j++) {
for(int k = 0; k <= colCount; k++) {
Cell cell = cells.get(j, k);
System.out.println(cell);//Null
System.out.println(cell.getStringValue());//Null
}
}
}

workbook.save(“out1.xlsx”); //The first worksheet is blank in the output file.

I have logged a ticket with an id “CELLSJAVA-41673” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,

Thanks for your using Aspose.Cells.

We have fixed the issue logged as CELLSJAVA-41673.

Please download and try the latest fix: Aspose.Cells for Java (Latest Version) and let us know your feedback.

Hi,

I verified the issue with the jar you provided. It is working now. Thanks for the quick fix. When is this fix available as a maven release?

Thank you
Muthu


Hi,


Good to know that your issue is resolved by the new fix. Well, you may use this fix as an official release on production server if you want. Anyways, our next official release is scheduled to be released (on Aspose site and on Maven rep.) within the next 7-9 days or so.

Once we publish the release, you will be notified here.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-41673) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.