Forum Discussion
MartinS
13 years agoOccasional Contributor
Hi Jain.
I tryed to make a script where i am accesing data in one sheet and inserting them to another sheet in one excel.
Workbook excelFile= Workbook.getWorkbook(new File("c://test.xls"));
Sheet inputSheet = excelFile.getSheet("Sheet1");
Sheet outputSheet = excelFile.getSheet("Sheet2");
Now i have excel file and sheet. And the only think i can do is to read cell content (Cell A = inputSheet.getCell(Columm, Row) ).So i tryed something with WritableWorkbook, sheet and cell. But i didnt find if WritableWorkbook can read existing excel file and then change content of this file. The only thing which works in some way is this sample:
import jxl.*;
import jxl.write.*
Workbook workbook = Workbook.getWorkbook(new File("d:\\test.xls"));
WritableWorkbook copy = Workbook.createWorkbook(new File("d:\\tmp.xls"), workbook);
Sheet sheet1 = copy.getSheet("Doc Input");
WritableSheet sheet2 = copy.getSheet("Doc Response");
CL = 0;
rows = sheet1.getRows();
for( tc_row in 1..rows-1){
WritableCell tmpA = sheet1.getCell(CL,tc_row);
String s1 = tmpA.getContents();
Label label = new Label(CL,tc_row,s1);
sheet2.addCell(label);
}
copy.write();
copy.close();
workbook.close();
But in this sample i am creating new excel file which i dont want I started to learn soapUI and Groovy 5 days ago so be patient with me please
Martin
I tryed to make a script where i am accesing data in one sheet and inserting them to another sheet in one excel.
Workbook excelFile= Workbook.getWorkbook(new File("c://test.xls"));
Sheet inputSheet = excelFile.getSheet("Sheet1");
Sheet outputSheet = excelFile.getSheet("Sheet2");
Now i have excel file and sheet. And the only think i can do is to read cell content (Cell A = inputSheet.getCell(Columm, Row) ).So i tryed something with WritableWorkbook, sheet and cell. But i didnt find if WritableWorkbook can read existing excel file and then change content of this file. The only thing which works in some way is this sample:
import jxl.*;
import jxl.write.*
Workbook workbook = Workbook.getWorkbook(new File("d:\\test.xls"));
WritableWorkbook copy = Workbook.createWorkbook(new File("d:\\tmp.xls"), workbook);
Sheet sheet1 = copy.getSheet("Doc Input");
WritableSheet sheet2 = copy.getSheet("Doc Response");
CL = 0;
rows = sheet1.getRows();
for( tc_row in 1..rows-1){
WritableCell tmpA = sheet1.getCell(CL,tc_row);
String s1 = tmpA.getContents();
Label label = new Label(CL,tc_row,s1);
sheet2.addCell(label);
}
copy.write();
copy.close();
workbook.close();
But in this sample i am creating new excel file which i dont want I started to learn soapUI and Groovy 5 days ago so be patient with me please
Martin
Related Content
Recent Discussions
- 32 minutes agoKLWallace
- 7 days agoruchisingh