From 6044b00b1e308dd28a7b5ed5dd6f0bf31de7eabd Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Mon, 2 May 2016 23:38:15 +0200
Subject: [PATCH] Fix formatting of cost rates in the Excel export

---
 R/exportInsuranceContract_xlsx.R | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/R/exportInsuranceContract_xlsx.R b/R/exportInsuranceContract_xlsx.R
index 7b57b66..bcf8b67 100644
--- a/R/exportInsuranceContract_xlsx.R
+++ b/R/exportInsuranceContract_xlsx.R
@@ -208,10 +208,13 @@ exportInsuranceContract.xlsx = function(contract, filename) {
   crow = crow + 4;
 
   # Cost structure:
-  costtable = as.data.frame.table(setInsuranceValuesLabels(contract$tarif$costs), responseName = "Kostensatz", dnn = c("Kostenart", "Basis", "Periode"), exclude=c(0))
+  costtable = as.data.frame.table(setInsuranceValuesLabels(contract$tarif$costs) )
+  colnames(costtable) = c("Kostenart", "Basis", "Periode", "Kostensatz");
   costtable = costtable[costtable[,"Kostensatz"]!=0.0000,]
-  writeDataTable(wb, sheet, costtable, startCol=1, startRow=crow+1, colNames=TRUE, rowNames=FALSE,
-                 tableStyle = "TableStyleMedium3", headerStyle = styles$tableHeader);
+  writeValuesTable(wb, sheet, costtable, crow=crow, ccol=1, tableName="Kosten", styles=styles, caption="Kosten");
+  # writeDataTable(wb, sheet, costtable, startCol=1, startRow=crow+1, colNames=TRUE, rowNames=FALSE,
+                 # tableStyle = "TableStyleMedium3", headerStyle = styles$tableHeader);
+  addStyle(wb, sheet, style=styles$cost0, rows=(crow+2):(crow+dim(costtable)[[1]]+1), cols=4, stack=TRUE);
   setColWidths(wb, sheet, cols = 1:50, widths = "auto", ignoreMergedCells = TRUE)
   crow = crow + dim(costtable)[[1]] + 3;
 
-- 
GitLab