1 year ago
#44409
Spam Garbage
How refactor Apache POI create cells legacy code?
I wrote simple method which generate excel file using data from Order class. I use createCell() method to put the data into this cells. createCell() method use identifier on which position of sheet I want to insert data. Is there a way to generate cells for each getter of Order class using java streams?
private static void createCell(Order order, Product product, Row row) {
Cell idCell = row.createCell(0);
Cell dateCell = row.createCell(1);
Cell destinationCell = row.createCell(2);
Cell productCell = row.createCell(3);
Cell productQuantityCell = row.createCell(4);
idCell.setCellValue(order.getOrderID());
dateCell.setCellValue(String.valueOf(order.getDate()));
destinationCell.setCellValue(order.getDestination());
productCell.setCellValue(product.getProductCode());
productQuantityCell.setCellValue(product.getProductQuantity());
}
java
java-stream
apache-poi
legacy-code
0 Answers
Your Answer