Excel Library
Excel Library
Excel-utils is a set of utilities for working with excel spreadsheets. It is based on the Apache POI library and the cscript utility for running vba scripts.
Below is a small example of working with an existing document. Here we create a sheet and fill it with data.
ExcelTask.java
package eu.ibagroup.easyrpa.excel.task; import eu.ibagroup.easyrpa.engine.annotation.ApTaskEntry; import eu.ibagroup.easyrpa.engine.apflow.ApTask; import eu.ibagroup.easyrpa.excel.SpreadsheetDocument; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellReference; @ApTaskEntry(name = "Create and read excel file") public class ExcelTask extends ApTask { private static final String FILE_PATH = "test.xlsx"; @Override public void execute() { try { SpreadsheetDocument doc = new SpreadsheetDocument(getClass().getResourceAsStream(FILE_PATH)); Sheet numbersSheet = doc.createSheet("Numbers"); for (int i = 0; i < 5; i++) { Row row = numbersSheet.createRow(i); for (int j = 0; j < 5; j++) { Cell cell = row.createCell(j); cell.setCellValue(String.format("%s%d", CellReference.convertNumToColString(j), i + 1)); } } doc.writeToFile(FILE_PATH); } catch (Exception e) { e.printStackTrace(); // do something } } }
Result sheet: