Sorry for late reply.. Data.xlsx is placed in my D: drive. with the data.
so please suggest where i am wrong.
I have already try to do that.. but same problem occur. i am stuck here from last few days, not able to move ahead so please suggest what should i do to solve that.
Hi,
I am displayed with the below issue.Please help to resolve
Code:
public class Read_xls {
public static void main(String[] args) {
Xls_Reader Reader = new Xls_Reader("C:\\Users\\ashwathi.p\\Book1.xls");
int count = Reader.getRowCount("data");
System.out.println(count);
}
}
Error:
org.apache.poi.openxml4j.exceptions.InvalidOperationException: Can't open the specified file: 'C:\Users\ashwathi.p\AppData\Local\Temp\poifiles\poi-ooxml--1529925134.tmp'
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:102)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:199)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:178)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:53)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:176)
at Xls_Reader.<init>(Xls_Reader.java:33)
at Read_xls.main(Read_xls.java:8)
Exception in thread "main" java.lang.NullPointerException
at Xls_Reader.getRowCount(Xls_Reader.java:44)
at Read_xls.main(Read_xls.java:9)
Thanks,
Ashwathi.P
Sorry Ashish,
I tried with new Excell sheet but still same issue occur. I am using MS Office2007 so i think it should work on that.
Plz.look into attached project with screenshot.
Hi Ashish,
I tried to do it on another machine its working so should i remove the eclipse once and run it again or what can be the reason behind that.
Hi All,
When we try to read from xslx file its a good idea to copy the file path rather than typing it. From properties menu copy
the file path and paste it into the code. That helped with "File not found error".
Hope this helps!!
Hi Chiravuri,
Thanks for suggestion,i tried it but its not working.
Finally i tried and got the solution and its working for me.
Ashish,
There was an file extension confusion. As per in Video ([b:3qvc1yjw]Module - 7[/b:3qvc1yjw]), I was trying to add .xlsx extension during creation of the Excel sheet, but it was adding it to the file name not as extension i.e. test.xlsx ([b:3qvc1yjw]in this case it didn't work[/b:3qvc1yjw])....Then i try to create an Excel file without Extension ([b:3qvc1yjw]in this case it works[/b:3qvc1yjw]).
I think in my system there is a default setting when ever i create a Excel file and add .xlsx to, it adds to its name not working as its extension.
THERE WAS A SMALL WINDOWS SETTING ISSUE . BUT ITS WORKING FINE NOW.