Invalid Argument exception

Hi, I am using Aspose.Cells for Java v2.1.0 (New Release) and is facing a problem when trying to read a .xls file. But the same file when saved in .xlsx format works fine.


java.lang.IllegalArgumentException: Invalid sheet index: 0
at com.aspose.cells.Worksheets.b(Unknown Source)
at com.aspose.cells.Worksheets.getSheet(Unknown Source)
at com.ccf.commerce.poi.helper.CCFSSHelper.getCellText(CCFSSHelper.java:144)
at com.ccf.commerce.poi.databean.CCFWBOrderUploadDataBean.populateBillingAddressInformations(CCFWBOrderUploadDataBean.java:142)
at com.ccf.commerce.poi.databean.CCFWBOrderUploadDataBean.populate(CCFWBOrderUploadDataBean.java:68)
at com.ibm.commerce.beans.DataBeanManager.directActivate(DataBeanManager.java:456)
at com.ibm.commerce.beans.DataBeanManager.activate(DataBeanManager.java:201)
at com.ibm.commerce.beans.DataBeanManager.activate(DataBeanManager.java:387)
at com.ibm.commerce.taglibs.base.tag.UseBean.doEndTag(UseBean.java:99)
at com.ibm._jsp._CCFOrderUploadDisplay._jspService(_CCFOrderUploadDisplay.java:693)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1694)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1643)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:113)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:82)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:819)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:216)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:347)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at com.ibm.commerce.struts.ECActionServlet.processRequest(ECActionServlet.java:237)
at com.ibm.commerce.struts.ECActionServlet.doGet(ECActionServlet.java:179)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1694)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1643)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:136)
at com.ibm.commerce.campaigns.filter.CampaignsFilter.doFilter(CampaignsFilter.java:131)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:121)
at com.ibm.commerce.likeminds.filter.LikeMindsFilter.doFilter(LikeMindsFilter.java:183)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:121)
at com.ibm.commerce.dynacache.filter.CacheFilter$2.run(CacheFilter.java:376)
at com.ibm.commerce.dynacache.filter.CacheFilter.doFilter(CacheFilter.java:507)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)

Hi,

Thank you for considering Aspose.

Please share your template XLS & XLSX files here to reproduce the issue. We will check it and get back to you soon.

Thank You & Best Regards,

Here are the files…To further clarify here are a few things…

These files can be read fine from a standalone java programme.
The issue arises when I try to run the same code from a J2EE applications
The J2EE application uploads the file to a server and reads them thru helper classes.
The same code reads the xlsx files correctly but throws this exception when trying to read the .xls file
I can see the .xls file uploaded to the server and can open that too.

Hi,

Thanks for providing us template files with some details.

Well, after checking your exception stack trace, we think it is not the exception that occurs during reading the template file. If an exception is thrown during reading template file, the trace should include segment like Workbook.open(…)… or so. As you did not give us your complete project, we do not know what happens after reading the template file. One possible reason for your issue is that you might have removed all worksheets from the workbook and call getSheet() before add any new one in the workbook.

So, we appreciate if you could provide a sample project , zip it and post it here to show the actual issue. And, we think you can print worksheets.size() just after opening the template file. and print the size again before calling CCFSSHelper.getCellText() where this exception is thrown. I think from the stack trace:
at com.aspose.cells.Worksheets.b(Unknown Source)
at com.aspose.cells.Worksheets.getSheet(Unknown Source)
at com.ccf.commerce.poi.helper.CCFSSHelper.getCellText(CCFSSHelper.java:144)

the debug code to print worksheets size should be in CCFSSHelper.getCellText() and just before calling Worksheets.getSheet()


And by the way, we have tested opening and then re-saving your template xls file and it works fine.


Thank you.