I have written Below lines of code are used for checking the xlsx file cell
protection while validation is done. The highlighted method gives exception
with large files.
Please can anyone give me some pointer whats
wrong with the method cell.getCellStyle(); when I am using for large
file(rows more than 44k apprx) .or any solution to resolve this issue.?
private String validateSheetProtection(XSSFSheet sheet, int
countOfProtectCols) {
int totalRowsOfSheet = sheet.getPhysicalNumberOfRows();
// check protection for the sheets and cells
for (int rowNo = 0; rowNo < totalRowsOfSheet; rowNo++) {
XSSFRow row = sheet.getRow(rowNo);
if (row != null) {
for (int i = 0; i < countOfProtectCols; i++) {
XSSFCell cell = row.getCell(i);
if(cell != null)
{
XSSFCellStyle style =
*cell.getCellStyle();//*Getting Exception over here throwing
java.lang.ArrayIndexOutOfBoundsException: -32768
if (style != null)
{
if (!(style.getLocked() || style.getHidden()))
{
return FILEPROTECTION_ERROR;
}
}
}
}
} else {
return FILETEMPLATE_INVALIDSHEETS_ERROR;
}
}
return null;
}
----------------------Genrated Errors--------
Caused by: java.lang.ArrayIndexOutOfBoundsException: -32768
at java.util.ArrayList.get(ArrayList.java:324)
at
org.apache.poi.xssf.model.StylesTable.getStyleAt(StylesTable.java:225)
at
org.apache.poi.xssf.usermodel.XSSFCell.getCellStyle(XSSFCell.java:481)
at
com.service.job.JobsService.validateSheetProtection(JobsService.java:384)
at
com.service.job.JobsService.validateXlsxColumns(JobsService.java:298)
at
com.service.job.JobsService.validateImportFile(JobsService.java:226)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
at $Proxy57.validateImportFile(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at
org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy58.validateImportFile(Unknown Source)
at
com.service.job.facade.JobsFacade.validateImportFile(JobsFacade.java:116)
at
com.service.job.facade.JobsFacade$$FastClassByCGLIB$$96a8f4ea.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at
org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at
com.ata.service.job.facade.JobsFacade$$EnhancerByCGLIB$$fa989021.validateImportFile(<generated>)
at
com.ata.web.i18n.ImportTranslationAction.doAction(ImportTranslationAction.java:75)
... 35 more
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/While-checking-the-xlsx-file-cell-protection-while-validation-throwing-java-lang-ArrayIndexOutOfBoun-tp5710475.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]