Tuesday, February 19, 2013

Selenium: To write data to a new spread sheet

To write data to a new spread sheet



import
java.io.File;
import
java.io.IOException;
import javax.swing.JOptionPane;
import
jxl.*;
import
jxl.write.*;
import
jxl.write.Number;
import
jxl.write.biff.RowsExceededException;
import
jxl.read.biff.BiffException;
 
public
class Framework
{
public static void main(String[] args) throws BiffException, IOException, RowsExceededException, WriteException
{
string numString = JOptionPane.showInputDialog("Enter a path");
WritableWorkbook workbook = Workbook.createWorkbook(
new File(numString )); //"D:\\output.xls"
WritableSheet sheet = workbook.createSheet(
"First Sheet", 0);
Label label =
new Label(0, 2, "some data");//(col,row,data) row col starts from 0
sheet.addCell(label);
// If data is string
Number number =
new Number(3, 4, 3.1459);//(col,row,data) row col starts from 0
sheet.addCell(number);
// If data is a number
workbook.write();
workbook.close();
}
}
//--------------------------------------------------------------------------------------------------

import
java.io.File;

import
java.io.IOException;
import javax.swing.JOptionPane;
import
jxl.*;
import
jxl.write.*;
import
jxl.write.Number;
import
jxl.write.biff.RowsExceededException;
import
jxl.read.biff.BiffException;
 
public
class Framework
{
public static void main(String[] args) throws BiffException, IOException, RowsExceededException, WriteException
{
string numString = JOptionPane.showInputDialog("Enter a path");
WritableWorkbook workbook = Workbook.createWorkbook(new File(numString )); //"D:\\output.xls"

WritableSheet sheet = workbook.createSheet("First Sheet", 0);
Label label = new Label(0, 2, "some data");//(col,row,data) row col starts from 0
sheet.addCell(label);
// If data is string
Number number = new Number(3, 4, 3.1459);//(col,row,data) row col starts from 0
sheet.addCell(number);
// If data is a number
workbook.write();
workbook.close();
}
}

No comments:

Post a Comment