Opening and updateing an excel sheet using jxl
Hello,
I am working using the following code example but I am unable to get it to work.
import jxl.*;
import jxl.write.*;
import java.io.*;
public class CreateExcel_JxlApi {
public static void main(String[] args) {
//create WorkbookSettings object
WorkbookSettings ws = new WorkbookSettings();
try{
//create work book
WritableWorkbook workbook = Workbook.getWorkbook(new File("C:/FileLocation/ExcelFile.xls"));
WritableWorkbook workbookCopy= Workbook.createWorkbook(new File("C:/FileLocation/NewExcelFile"), workbook);
System.out.println("Did excel file create?");
//create work sheet
WritableSheet workSheet = null;
workSheet = workbook.createSheet("Test Report" ,3);
SheetSettings sh = workSheet.getSettings();
//write to datasheet
workSheet.addCell(new jxl.write.Label(10,0,"User Name"));
workSheet.addCell(new jxl.write.Label(11,0,"Password2"));
workSheet.addCell(new jxl.write.Label(13,0,"Another one for the Road"));
//write to the excel sheet
workbook.write();
//close the workbook
workbook.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
What I am trying to do is:
1. Open the excel worksheet with Groovy using jxl.
2. Write New Data onto the same Excel worksheet in a different Row.
3. Make Sure the previous data on the worksheet does not erase.
There have been some threads in the past but they either don't explain how it was accomplished or any links relating to the post are broken.
Thanks for looking.