Excel operations - script to Java migration
For the Excel operations, not all of the script operations from the Script API are implemented in the Java™ API. Alternative Java code is provided for those script operations that are not implemented in the Java API.
The Excel methods can be achieved by using the HSSF library:
Script operation | Alternative Java code |
---|---|
createExcelCell | HSSFCell hssfCell = row.createCell(columnIndex); |
createExcelCellStyle | HSSFCellStyle hssfCellStyle= workBook.createCellStyle(); |
createExcelSheet | HSSFSheet sheet = workBook.createSheet(); |
createFont | HSSFFont hssfFont = workBook.createFont(); |
createRow | HSSFRow hssfRow = sheet.createRow(rowIndex); |
ExcelBook | Load
com.ibm.ccd.common.excel.impl.hssf. HssfIExcelBookFactory then invoke createIExcelBook() |
getCellObj | HSSFRow.getCell(index) |
getDateCellValue | HSSFCell.getDateCellValue(); |
getDateFromDoubleValue | HSSFDateUtil.getJavaDate
(argument.doubleValue()); |
getExcelCell | HSSFRow row = sheet.getRow(iRowIndex); HSSFCell cell = row.getCell((short)iColIndex); cell.getStringCellValue() |
getExcelCellEncoding | HSSFCell.getEnconding() |
getExcelCellType | HSSFCell.getCellType() |
getExcelRow | HSSFSheet.getRow(rowIndex.intValue()); |
getExcelSheet | HSSFWorkbook.getSheetAt(int) Or HSSFWorkbook.getSheet (String) |
getExcelSheets | HSSFWorkbook.getNumberOfSheets();
repeat through each of them using HSSFWorkbook.getSheetAt(i); |
getFirstCellNum | HSSFRow.getFirstCellNum() |
getFirstRowNum | HSSFSheet.rowIterator(); |
getLastCellNum | HSSFRow.getLastCellNum() |
getLastRowNum | HSSFSheet .getLastRowNum() |
getNbRows | HSSFSheet. getPhysicalNumberOfRows() |
getNumericCellValue | HSSFCell.getNumericCellValue(); |
getStringCellValue | HSSFCell.getStringCellValue(); |
saveToDocStore | Upload using docstore exposed APIs |
setAlignment | HSSFCellStyle.setAlignment() |
setBoldWeight | HSSFFont.setBoldweight() |
setBorderBottom | HSSFCellStyle.setBorderBottom |
setBorderLeft | HSSFCellStyle.setBorderLeft |
setBorderRight | HSSFCellStyle.setBorderRight |
setBorderTop | HSSFCellStyle.setBorderTop |
setBottomBorderColor | HSSFCellStyle.setBottomBorderColor |
setCellType | HSSFCell.setCellType(); |
setColor | HSSFFont.setColor(color) |
setDataFormat | HSSFCellStyle.setDataFormat() |
setDateCellValue | HSSFCell.setCellValue(); |
setExcelStyle | HSSFCell.setCellStyle(); |
setFillBackgroundColor | HSSFCellStyle.setFillForegroundColor() |
setFillForegroundColor | HSSFCellStyle.setFillForegroundColor() |
setFillPattern | HSSFCellStyle.setFillPattern() |
setFont | HSSFCellStyle.setFont() |
setFontHeight | HSSFFont .setFontHeight() |
setFontName | HSSFFont setFontName(sFontName); |
setIndention | HSSFCellStyle.setIndention() |
setItalic | HSSFFont.setItalic() |
setLeftBorderColor | HSSFCellStyle.setLeftBorderColor |
setNumericCellValue | HSSFCell.setCellValue() |
setRightBorderColor | HSSFCellStyle.setRightBorderColor |
setStrikeout | HSSFFont.setStrikeout() |
setStringCellValue | HSSFCell.setCellValue() |
setTopBorderColor | HSSFCellStyle.setTopBorderColor() |
setUnderline | HSSFFont.setUnderline() |
setVerticalAlignment | HSSFCellStyle.setVerticalAlignmentT() |
setWrapText | HSSFCellStyle.setWrapText() |