download this jar and add to library
http://www.java2s.com/Code/Jar/s/Downloadsaxon9108jar.htm
I have downloaded the jar Saxon 9.4.0.7 to the Project. The error remains the same. I tried to write to a file separately, That is failing. But both have same error. Open the excel file says "Excel error "cannot open file because the file format or file extension is not valid." I am using using pirated version of Microsoft office Professional 2013 . could this be a problem?
File src = new File("C:\\Users\\xxx\\Documents\\Selenium Excels\\writeToExcel.xlsx");
FileInputStream fis = new FileInputStream(src);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet Sheet1 = wb.getSheetAt(0);
Sheet1.getRow(0).createCell(2).setCellValue("Pass");
FileOutputStream out = new FileOutputStream(src);
wb.write(out);
wb.close();
Error for above lies ------
Exception in thread "main" java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.util.zip.ZipInputStream.read(Unknown Source)
at org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.read(ZipSecureFile.java:143)
at java.io.FilterInputStream.read(Unknown Source)
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource$FakeZipEntry.<init>(ZipInputStreamZipEntrySource.java:130)
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.<init>(ZipInputStreamZipEntrySource.java:57)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:92)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:273)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:274)
at writeToExcel.riteToExcel.main(riteToExcel.java:17)
Core Hybrid Project Error-----------------
java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.util.zip.ZipInputStream.read(Unknown Source)
at org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.read(ZipSecureFile.java:143)
at java.io.FilterInputStream.read(Unknown Source)
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource$FakeZipEntry.<init>(ZipInputStreamZipEntrySource.java:130)
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.<init>(ZipInputStreamZipEntrySource.java:57)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:92)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:273)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:274)
at com.qtpselenium.xls.read.Xls_Reader.<init>(Xls_Reader.java:35)
at com.qtpselenium.test.DriverScript.start(DriverScript.java:65)
at com.qtpselenium.test.DriverScript.main(DriverScript.java:39)
Exception in thread "main" java.lang.NullPointerException
at com.qtpselenium.xls.read.Xls_Reader.getRowCount(Xls_Reader.java:46)
at com.qtpselenium.test.DriverScript.start(DriverScript.java:68)
at com.qtpselenium.test.DriverScript.main(DriverScript.java:39)
I will run the script in a different machine and post the comments.
Thanks again
Open browser openBrowser PASS
Navigate to website navigate PASS
CheckTitle verifyTitle PASS
Finally worked in my own machine after including the jars as you suggested.
Thanks so much for your help.