Refactor code to populate a spreadsheet My code looks ugly. What can you recommend? I already know about Enum; maybe it's a good variant for this situation.  Anything else?

   private void writerContent(Integer firstRow, List&lt;Record&gt; records){
        int firstColumn=0;
        int lastColumn=7;
        XSSFSheet sheet = workBook.getSheetAt(0);
        for (int lineId=firstRow;lineId&lt;records.size();lineId++)   {
            Row row = sheet.getRow(lineId);
            for (int columnId=firstColumn;columnId&lt;lastColumn;columnId++){
                switch (columnId){
                    case 0:  row.createCell(columnId).setCellValue(records.get(lineId).getNumber()); break;
                    case 1:  row.createCell(columnId).setCellValue(records.get(lineId).getName());  break;
                    case 2:  row.createCell(columnId).setCellValue(records.get(lineId).getCode());   break;
                    case 3:  row.createCell(columnId).setCellValue(records.get(lineId).getCount());  break;
                    case 4:  row.createCell(columnId).setCellValue(records.get(lineId).getSimultaneouslyProcessedProducts());  break;
                    case 5:  row.createCell(columnId).setCellValue(records.get(lineId).isSimultaneousProcessing());   break;
                    case 6:  row.createCell(columnId).setCellValue(records.get(lineId).getInterchangeability()); break;
                }
            }
        }

    }
Why don't you unroll the inner loop?  So the final method will be like

private void writerContent(Integer firstRow, List&lt;Record&gt; records) {
    XSSFSheet sheet = workBook.getSheetAt(0);
    for (int lineId=firstRow; lineId&lt;records.size(); lineId++) {
        Record rec = records.get(lineId);
        Row row = sheet.getRow(lineId);
        row.createCell(0).setCellValue(rec.getNumber());
        row.createCell(1).setCellValue(rec.getName());  
        row.createCell(2).setCellValue(rec.getCode()); 
        row.createCell(3).setCellValue(rec.getCount());
        row.createCell(4).setCellValue(rec.getSimultaneouslyProcessedProducts());  
        row.createCell(5).setCellValue(rec.isSimultaneousProcessing());
        row.createCell(6).setCellValue(rec.getInterchangeability());
    }
}