This project has moved. For the latest updates, please go here.

Error using both RepeatColumns and RepeatRows

Oct 17, 2013 at 3:13 AM
I'm getting an issue when I add both of these into a workbook, but either on their own works fine.
 worksheet.PrinterSettings.RepeatColumns = new ExcelAddress("A:B"); 
 worksheet.PrinterSettings.RepeatRows = new ExcelAddress("1:1"); 
Comment out either line and it works fine, but if you leave them both in, I get an error message from Excel:
Print titles must be contiguous and complete rows or columns.
Anyone encounter this before?
Oct 18, 2013 at 7:04 PM
I've encoutered the same problem.

When looking into the XML files (workbook.xml) I see the following line for the Titles:
<definedName name="_xlnm.Print_Titles" localSheetId="0">'Inventory'!$1:$2,'Inventory'!$A:$G,'Inventory'!$1:$2</definedName>

When opening the document in Excel I receive the error message above.

After setting the titles in Excel again for this file, saving the file and looking into the XML files again, the line has been changed to:
<definedName name="_xlnm.Print_Titles" localSheetId="0">Inventory!$A:$G,Inventory!$1:$2</definedName>

The error is (somehow) caused because the rows are double added.

I've not been able to debug code so far, but it somehow adds the rows again.

This is the code I've been using for adding the Titles (it's the code from the sample code):

worksheet.PrinterSettings.RepeatRows = worksheet.Cells["1:2"];
worksheet.PrinterSettings.RepeatColumns = worksheet.Cells["A:G"];
Mar 12, 2014 at 2:28 PM
Edited Mar 12, 2014 at 2:29 PM
I have the same problem. It seems to be a problem with the setters. This unit test fails but should not, right?
    public void TestRepeatRowsAndColumnsTest()
        var p = new ExcelPackage();

        var w = p.Workbook.Worksheets.Add("RepeatRowsAndColumnsTest");

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

        Assert.IsNotNull(w.PrinterSettings.RepeatRows); // Fails!
I use EPPlus in version
Sep 19, 2014 at 11:59 AM
I have the same problem. Cannot set both at the same time with EPPlus.
I use EPPlus too.

Any hope that this will be fixed.

Sep 19, 2014 at 12:58 PM
Hi Daniel,

in 4.0.0 it works. Even if it's called beta it is stable enough for me until now. Don't know, if it is an option for you, too.
Sep 20, 2014 at 9:20 AM

I tried 4.0.0 Beta and using both RepeatedColumns and RepeatedRows at the same time works.
But now I found this Bug in 4.0.0:

Is there any expected time frame for a RTM version of 4.0.0?

Mar 12, 2015 at 5:41 PM
Another workaround is to revert to 3.1.2, as this is working in that build