final ExcelReportSetting reportSetting,
final Map<Object, Object> data) throws ProTransException {
String excelPath = getExcelPath();
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = getSheet(wb, 1, new int[] { 4000 });
int currentRow = 0;
HSSFRow row;
CellStyle cellStyle = new CellStyle(wb);
row = sheet.createRow((short) currentRow++);
createCell(row, cellStyle.getStyle18Bold(), (short) 2,
"Ordrereserve takstol");
row = sheet.createRow((short) currentRow++);
row = sheet.createRow((short) currentRow++);
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(),
HSSFCellStyle.BORDER_THIN, null, null,
HSSFCellStyle.BORDER_THIN), (short) 1, "Ekstern");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(),
HSSFCellStyle.BORDER_THIN, null, null,
HSSFCellStyle.BORDER_THIN), (short) 3, "Intern");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(),
HSSFCellStyle.BORDER_THIN, null, null,
HSSFCellStyle.BORDER_THIN), (short) 5, "");
row = sheet.createRow((short) currentRow++);
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
HSSFCellStyle.BORDER_THIN, HSSFCellStyle.BORDER_THIN,
HSSFCellStyle.BORDER_THICK), (short) 0, "Ordrereserve");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(),
HSSFCellStyle.BORDER_THIN, null, null,
HSSFCellStyle.BORDER_THICK), (short) 1, "Antall");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
HSSFCellStyle.BORDER_THIN, null, HSSFCellStyle.BORDER_THICK),
(short) 2, "Sum");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(),
HSSFCellStyle.BORDER_THIN, null, null,
HSSFCellStyle.BORDER_THICK), (short) 3, "Antall");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
HSSFCellStyle.BORDER_THIN, null, HSSFCellStyle.BORDER_THICK),
(short) 4, "Sum");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(),
HSSFCellStyle.BORDER_THIN, null, null,
HSSFCellStyle.BORDER_THICK), (short) 5, "Totalt");
row = sheet.createRow((short) currentRow++);
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, HSSFCellStyle.BORDER_THIN, null), (short) 0,
"Ikke prosjektert");
Map<String, AntallSum> reportSum = (Map<String, AntallSum>) data
.get("Sum");
AntallSum antallSum = reportSum.get("IkkeProsjektertEkstern");
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null, null,
null, null), (short) 1, null, antallSum != null ? Double
.valueOf(antallSum.getNumberOf()) : 0);
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null, null,
HSSFCellStyle.BORDER_THIN, null), (short) 2, null,
antallSum != null ? Double.valueOf(antallSum.getSum()
.doubleValue()) : 0);
antallSum = reportSum.get("IkkeProsjektertIntern");
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null, null,
null, null), (short) 3, null, antallSum != null ? Double
.valueOf(antallSum.getNumberOf()) : 0);
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null, null,
HSSFCellStyle.BORDER_THIN, null), (short) 4, null,
antallSum != null ? Double.valueOf(antallSum.getSum()
.doubleValue()) : 0);
createFormulaCell(row, (short) (5), "C5+E5", null);
row = sheet.createRow((short) currentRow++);
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, HSSFCellStyle.BORDER_THIN, null), (short) 0,
"Prosjektert");
antallSum = reportSum.get("ProsjektertEkstern");
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null, null,
null, null), (short) 1, null, antallSum != null ? Double
.valueOf(antallSum.getNumberOf()) : 0);
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null, null,
HSSFCellStyle.BORDER_THIN, null), (short) 2, null,
antallSum != null ? Double.valueOf(antallSum.getSum()
.doubleValue()) : 0);
antallSum = reportSum.get("ProsjektertIntern");
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null, null,
null, null), (short) 3, null, antallSum != null ? Double
.valueOf(antallSum.getNumberOf()) : 0);
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null, null,
HSSFCellStyle.BORDER_THIN, null), (short) 4, null,
antallSum != null ? Double.valueOf(antallSum.getSum()
.doubleValue()) : 0);
createFormulaCell(row, (short) (5), "C6+E6", null);
row = sheet.createRow((short) currentRow++);
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
HSSFCellStyle.BORDER_THIN, HSSFCellStyle.BORDER_THIN,
HSSFCellStyle.BORDER_THICK), (short) 0, "Totalt");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
HSSFCellStyle.BORDER_THIN, null, HSSFCellStyle.BORDER_THICK),
(short) 1, "");
createFormulaCell(row, (short) (2), "C5+C6", cellStyle.getStyle(
cellStyle.getFont10(), null, HSSFCellStyle.BORDER_THIN,
HSSFCellStyle.BORDER_THIN, HSSFCellStyle.BORDER_THICK));
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
HSSFCellStyle.BORDER_THIN, null, HSSFCellStyle.BORDER_THICK),
(short) 3, "");
createFormulaCell(row, (short) (4), "E5+E6", cellStyle.getStyle(
cellStyle.getFont10(), null, HSSFCellStyle.BORDER_THIN,
HSSFCellStyle.BORDER_THIN, HSSFCellStyle.BORDER_THICK));
createFormulaCell(row, (short) (5), "F5+F6", cellStyle.getStyle(
cellStyle.getFont10(), null, HSSFCellStyle.BORDER_THIN, null,
HSSFCellStyle.BORDER_THICK));
row = sheet.createRow((short) currentRow++);
row = sheet.createRow((short) currentRow++);
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, null), (short) 0, "Grunnlag");
row = sheet.createRow((short) currentRow++);
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, HSSFCellStyle.BORDER_THICK), (short) 0, "Type");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, HSSFCellStyle.BORDER_THICK), (short) 1, "Avdeling");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, HSSFCellStyle.BORDER_THICK), (short) 2, "Kundenr");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, HSSFCellStyle.BORDER_THICK), (short) 3, "Navn");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, HSSFCellStyle.BORDER_THICK), (short) 4, "Ordrenr");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, HSSFCellStyle.BORDER_THICK), (short) 5,
"Egenproduksjon");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, HSSFCellStyle.BORDER_THICK), (short) 6, "Frakt");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, HSSFCellStyle.BORDER_THICK), (short) 7, "Prod.dato");
createCell(row, cellStyle.getStyle(cellStyle.getFont10Bold(), null,
null, null, HSSFCellStyle.BORDER_THICK), (short) 8, "Transport");
List<OrdreReserveTakstol> reportBasis = (List<OrdreReserveTakstol>) data
.get("Basis");
row = sheet.createRow((short) currentRow++);
for (OrdreReserveTakstol ordre : reportBasis) {
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null,
null, null, null), (short) 0, ordre.getType());
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null,
null, null, null), (short) 1, ordre.getProductAreaGroup());
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null,
null, null, null), (short) 2, ordre.getCustomerNr());
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null,
null, null, null), (short) 3, ordre.getCustomerName());
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null,
null, null, null), (short) 4, ordre.getOrderNr());
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null,
null, null, null), (short) 5, null, ordre
.getOwnProduction() != null ? ordre.getOwnProduction()
.doubleValue() : 0);
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null,
null, null, null), (short) 6, null,
ordre.getDeliveryCost() != null ? ordre.getDeliveryCost()
.doubleValue() : 0);
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null,
null, null, null), (short) 7,
ordre.getProductionDate() != null ? Util.formatDate(ordre
.getProductionDate(), Util.SHORT_DATE_FORMAT) : "");
createCell(row, cellStyle.getStyle(cellStyle.getFont10(), null,
null, null, null), (short) 8,
ordre.getTransportWeek() != null ? ""
+ ordre.getTransportYear() + "/"
+ ordre.getTransportWeek() : "");
row = sheet.createRow((short) currentRow++);
}
openExcelFile(reportSetting.getExcelReportType().getExcelFileName()
+ ".xls", excelPath, wb, true);
}