Tuesday, February 19, 2013

Selenium: To display all the Rows and Columns in an excel sheet

To display all the rows and columns inside Spreadsheet

//All the related API and JARS should be added (Read previous program ) for more details




import
java.io.File;
import
java.io.IOException;
//import java.util.Locale;
//import javax.swing.JOptionPane;
import
jxl.*;
import
jxl.read.biff.BiffException;
//import jxl.write.*;
 
public
class Framework
{
public static void main(String[] args) throws BiffException, IOException
{
String sPath=JOptionPane.showInputDialog("Enter excel Path");//"D:\\Selenium\\sample.xls"
Workbook workbook = Workbook.getWorkbook(
new File ("sPath"));//
Sheet sheet = workbook.getSheet(0); //workbook.getSheet("Sheet1")
for (int i = 0; i < sheet.getRows(); i++)
{
for (int j = 0; j < sheet.getColumns(); j++)
{
Cell cell = sheet.getCell(j,i);
//getcell(col,row)
System.
out.print(cell.getContents()+" ");
}
System.
out.println("");// or System.out.print("\n");
}
workbook.close();
}
}

1 comment:

  1. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition

    selenium training in bangalore|

    ReplyDelete