Forum Discussion
Hi Jason1,
In my way using of POI or JXL will be a good approach, as you can moulde your groovy code according to your need.
If you are facing any issue with groovy code please attach a screenshot of error, may be we can help.
This is the code I used in SoapUI:
def filePath = "C:/Work/Data/Sasktel/Commercail Wireless/1. Internal Flags/OR/OR-ICT00345.xlsx"
FileInputStream inputStream = new FileInputStream(new File(filePath));
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
XSSFSheet sheet = workbook.getSheetAt(0);
rowNumInt = rowNumInt + 1
Row row = sheet.createRow(rowNumInt);
Cell cell = row.createCell(25);
cell.setCellValue(result);
inputStream.close();
FileOutputStream outputStream = new FileOutputStream(filePath);
workbook.write(outputStream);
workbook.close();
outputStream.close();
This is the exception I get:
ERROR:java.lang.NoClassDefFoundError: org/openxmlformats/schemas/spreadsheetml/x2006/main/CTExtensionList
java.lang.NoClassDefFoundError: org/openxmlformats/schemas/spreadsheetml/x2006/main/CTExtensionList
Do you have a solution to fix this?
Thanks
- HimanshuTayal6 years agoCommunity Hero
Hi Jason1,
Hope below thread will help you in solving your problem:
java lang NoClassDefFoundError with Apache POI
- aaronpliu6 years agoFrequent Contributor
firstly, to ensure you import required package, as follows:
import org.apache.poi.ss.usermodel.Cell import org.apache.poi.ss.usermodel.Row import org.apache.poi.xssf.usermodel.XSSFSheet import org.apache.poi.xssf.usermodel.XSSFWorkbook
secondly, you'd better to use try...catch for any I/O operation, as like
try { FileOutputStream outputStream = new FileOutputStream(FILE_NAME) workbook.write(outputStream) workbook.close() } catch (FileNotFoundException e) { e.printStackTrace() } catch (IOException e) { e.printStackTrace() }
- Olga_T6 years agoSmartBear Alumni (Retired)
Hi all,
aaronpliu, HimanshuTayal, thank you for your time looking into this!
Jason1, did you manage to accomplish your task? If your question was answered, don't hesitate to mark the reply that helped you as a solution to this topic. You can do this by clicking the Accept as Solution button below the appropriate reply.
We are looking forward to hearing from you.
Related Content
- 2 years ago
Recent Discussions
- 8 hours ago
- 24 hours ago