Search code examples
c#excel-interopepplusepplus-4

How can I set what is called "PrintTitleRows" in Excel Interop using EPPlus?


I've got this Excel Interop code:

_xlSheetFillRateByDCByLocation.PageSetup.PrintTitleRows = String.Format("${0}:${0}", BYDCBYLOC_HEADING_ROW);

I want to accomplish the same with EPPlus.

I tried this:

locationWorksheet.PrinterSettings.RepeatColumns.Rows = BYDCBYLOC_HEADING_ROW;

...but "RepeatColumns.Rows" is a readonly property, and thus cannot be assigend to.

I found this:

locationWorksheet.PrinterSettings.ShowHeaders = true;

...but I don't know if I'm barking up the wrong tree with that.

What is the analogue in EPPlus to Excel Interop's PrintTitleRows?


Solution

  • You just need to give it a proper ExcelAddress object like this:

    worksheet.PrinterSettings.RepeatRows = new ExcelAddress("$1:$1");
    worksheet.PrinterSettings.RepeatColumns = new ExcelAddress("$A:$A");