Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facing Issue while reading data from excel in selenium with Java. #30

Open
ShivaliGuleria opened this issue Nov 29, 2021 · 0 comments
Open

Comments

@ShivaliGuleria
Copy link

CODE
package DataDrivenTesting;

import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.xssf.usermodel.*;

public class ReadingDataFromExcel {

public static void main(String[] args) throws Exception  {

	File Src = new File("C://Users//JOHN//Desktop//version.xlsx");
	FileInputStream file= new FileInputStream(Src);
	
	XSSFWorkbook workbook = new  XSSFWorkbook(file);  //get the workbook
	 XSSFSheet sheet = workbook.getSheet("Sheet 1");  //Providing the sheet name
	 int rowcount = sheet.getLastRowNum();           //Return the row count
	 int columncount = sheet.getRow(0).getLastCellNum(); //return the cell count
	 
	for(int i=0;i<rowcount;i++) 
	{
	XSSFRow Currentrow= sheet.getRow(i);   //Focused on current row
	for(int j=0;j<columncount;j++)
	{	
		String Value = Currentrow.getCell(j).toString();  //Read value from cell
		System.out.print(" " +Value);
		
	}
       System.out.println();
       workbook.close();
    
}
}}

ERROR
Exception in thread "main" java.lang.NoSuchMethodError: 'byte[] org.apache.commons.io.IOUtils.byteArray(int)'
at org.apache.commons.io.output.AbstractByteArrayOutputStream.needNewBuffer(AbstractByteArrayOutputStream.java:104)
at org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream.(UnsynchronizedByteArrayOutputStream.java:51)
at org.apache.poi.util.IOUtils.peekFirstNBytes(IOUtils.java:110)
at org.apache.poi.poifs.filesystem.FileMagic.valueOf(FileMagic.java:209)
at org.apache.poi.openxml4j.opc.internal.ZipHelper.verifyZipHeader(ZipHelper.java:143)
at org.apache.poi.openxml4j.opc.internal.ZipHelper.openZipStream(ZipHelper.java:175)
at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:130)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:312)
at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:47)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:296)
at DataDrivenTesting.ReadingDataFromExcel.main(ReadingDataFromExcel.java:15)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant