I'm not able to read xlsm file using Apache POI. I'm getting the error java.lang.StringIndexOutOfBoundsException: String index out of range:-1.
My program looks like:
FileInputStream file=new FileInputStream(new File(path));
out.print("aaaaaa");
Workbook workbook=null;out.print("1111111");
workbook=WorkbookFactory.create(file);
out.print("222222");
The 22222 never prints and I get the exception. The aaaaaaa and 111111 print.
I have downloaded all the latest jars as per Error while reading an xlsm file using POI Framework in Java I have tried with XSSFWorkbook. I have tried passing File object instead of FileInputStream as seen in some SO answers.
It's a read only xlsm My Java version 1.7.
The program worked fine when i tried with a new xlsm file, also worked fine with other readonly xlsm file(also protected, but having different template).
Could it mean that maybe there is some issue with my particular xlsm file template? Or am I missing anything else? Can someone help in fixing this?
UPDATE: I put my code block in a small java class and directly copied to server into a folder outside my web application folder and it works fine there... Could it be svn related issue?