Я создаю таблицу Excel на Java, как показано ниже.Есть ли опция в стиле или объекте листа, где мы можем указать порядок сортировки столбцов во время создания вместо того, чтобы делать это в Excel?Я хочу получить, где это сортирует по 4-му столбцу.
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Account by Acct Event-PC");
Font headerFont = workbook.createFont();
headerFont.setBold(true);
CellStyle style = workbook.createCellStyle();
style.setWrapText(true);
Font font = workbook.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setFont(font);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
//header row
Row headerRow = sheet.createRow(0);
for(int i = 0; i < HEADER_FIELDS.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(HEADER_FIELDS[i]);
cell.setCellStyle(style);
}
//data rows
for(int i = 1; i <= tableData.getRecords().size(); i++) {
Row row = sheet.createRow(i);
A8SPT138 record = (A8SPT138) tableData.getRecords().get(i-1);
row.createCell(0).setCellValue(record.getAccountingEvent());
row.createCell(1).setCellValue(record.getA8spt002().getDescription()) ;
row.createCell(2).setCellValue(record.getPostCode());
row.createCell(3).setCellValue(record.getA8spt143().getDescription()) ;
row.createCell(4).setCellValue(record.getAcqCode());
row.createCell(5).setCellValue(record.getA8spt004().getDescription());
row.createCell(6).setCellValue(record.getChartOfAccountI());
row.createCell(7).setCellValue(SamsConstants.JSP_FORMAT.format(SamsConstants.DATE_UPDATED_FORMAT
.parse(record.getDateUpdated())));
row.createCell(8).setCellValue(record.getUpdatedBy());
}
Еще раз спасибо.