From 973e47ae51b7fffd0516d12b69a6cbc4133b8a01 2020-09-18 11:15:35 From: Lance Edgar Date: 2020-09-18 11:15:35 Subject: [PATCH] Allow overriding column header labels when writing Excel file --- diff --git a/rattail/excel.py b/rattail/excel.py index 6a21e418a295ddee5ea0564d4a558da222abb9fb..445f1af3ef54300eeaed5c2f82d9b57b0152ca4d 100644 --- a/rattail/excel.py +++ b/rattail/excel.py @@ -117,10 +117,13 @@ class ExcelWriter(object): self.sheet.title = sheet_title self.number_formats = number_formats - def write_header(self): + def write_header(self, labels=None): font = Font(bold=True) for i, field in enumerate(self.fields, 1): - cell = self.sheet.cell(row=1, column=i, value=field) + value = field + if labels and field in labels: + value = labels[field] + cell = self.sheet.cell(row=1, column=i, value=value) cell.font = font def write_row(self, data, row=None):