}
currentRow = setInfoText(excelSheet, infoTextTop, startCell,
currentRow, cellStyle.getStyle10Bold());
HSSFRow row = excelSheet.createRow((short) currentRow++);
int columnCount = table.getColumnCount();
int rowCount = table.getRowCount();
// kolonne som har blitt lagt til pga utskrift av radnummer
int addedColumn = 0;
// dersom radnummer skal skrives ut
if (writeRowNumber) {
excelSheet.setColumnWidth((short) 0, (short) 900);
startCell += 1;
if (groupSumColumn != null) {
groupSumColumn += 1;
}
addedColumn = 1;
}
// Skriver ut kolonneoverskrift
createColumnHeadings(row, cellStyle.getHeadingStyle(),
table.getModel(), 0, columnCount, startCell, notVisibleColumns);
// Data
int j;
int k;
int l = currentRow;
int rowNumber = 0;
// det skal legges til en summeringsformel p� sluttet
if (sumFormula != null) {
sumFormula.setFromRow(l + 1);
}
HSSFCell cell;
String groupValue = "";
List<ExcelGroupSum> formulaCells = new ArrayList<ExcelGroupSum>();
String groupSumValue = "";
ExcelGroupSum currentExcelGroupSum = null;
// G�r gjennom alle rader og kolonner
for (j = currentRow; j < rowCount + currentRow; j++) {
rowNumber++;
// dersom data skal grupperes
if (groupColumn != null
&& !table.getValueAt(j - currentRow, groupColumn).equals(
groupValue)) {
// setter forrige grupperingssum
if (currentExcelGroupSum != null) {
currentExcelGroupSum.setToRow((short) (l));
formulaCells.add(currentExcelGroupSum);
groupSumValue = "";
currentExcelGroupSum = null;
rowNumber = 1;
}
// henter grupperingsverdi og setter ny overskrift for
// gruppering
groupValue = (String) table.getValueAt(j - currentRow,
groupColumn);
row = excelSheet.createRow((short) l);
createCell(row, cellStyle.getGroupStyle(),
(short) (startCell - addedColumn), groupValue);
excelSheet.addMergedRegion(new Region((short) l, (short) 0,
(short) l, (short) (columnCount + addedColumn
- notVisibleColumnsSize - 1)));
l++;
}
setLabelInfo(labelInfo, infoString, j);
row = excelSheet.createRow((short) l);
l++;
// dersom det skal skrives ut rad nummer
if (writeRowNumber) {
cell = row.createCell((short) (startCell - 1));
cell.setCellValue(rowNumber);
}
// g�r gjennom alle kolonner for rad
for (k = startCell; k < columnCount + startCell; k++) {
// dersom kolonne skal v�re synlig
if (notVisibleColumns == null
|| !notVisibleColumns.contains(k - startCell)) {
setColumnSize(colSize, excelSheet, startCell, addedColumn,
k);
cell = row.createCell((short) k);
// dersom celle har verdi
if (table.getValueAt(j - currentRow, k - startCell) != null) {
// dersom det er grupperingssum satt og den er ulik
// forrige
if (groupSumValueColumn != null
&& !table.getValueAt(j - currentRow,
groupSumValueColumn).equals(
groupSumValue)) {
groupSumValue = (String) table.getValueAt(j
- currentRow, groupSumValueColumn);
if (currentExcelGroupSum != null) {
currentExcelGroupSum.setToRow((short) (l - 1));
formulaCells.add(currentExcelGroupSum);
}
if (groupResultColumn != null
&& groupSumColumn != null) {
currentExcelGroupSum = new ExcelGroupSum(
(short) l,
row
.createCell((short) (groupResultColumn
.shortValue() + addedColumn)),
groupSumColumn.shortValue(),
DayEnum.getDayColorIndex(groupSumValue),
wb.createCellStyle());