B. Clay Shannon B. Clay Shannon - 1 year ago 148
C# Question

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?

Answer Source

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");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download