This project has moved and is read-only. For the latest updates, please go here.

Issue(s) with PrinterSettings.RepeatColumns


Issuing a PrinterSettings.RepeatColumns on an excel file that has either been written to disk (editing an existing xlsx or issuing a and then issuing a RepeatColumns) causes an error. The same error can also be triggered by issuing a sheet.DeleteColumn and then the RepeatColumns.

In either case, .Net triggers this error:
Row cannot be less than 1. Parameter name: value.
Example code in VB.Net that triggers:
Dim destFileInfo As FileInfo = New FileInfo(DestFile)
Using dstPackage As ExcelPackage = new ExcelPackage(destFileInfo)
   Dim SNRSheet As ExcelWorksheet 
   '[...snipped code to copy data between documents...]
   SNRSheet.deleteColumn(StageCol, LastColNum+2)
   SNRSheet.PrinterSettings.RepeatColumns = SNRSheet.Cells("A:A")
End using
Not sure if this is related or not, but in this code, if I move the RepeatColumns line up above the deleteColumns line, then no error is triggered. But the RepeatColumns action is lost during the process, so it acts like that code didn't exist.

Another example that triggers this:
Dim file = New FileInfo(filePath)
If file.Exists Then
End If

Using p = New ExcelPackage(file)
    Dim wb = p.Workbook
    Dim ws = If(wb.Worksheets.FirstOrDefault(), wb.Worksheets.Add("Sheet1"))

    For r As var = 1 To 20
        For c As var = 1 To 20
            ws.Cells(r, c).Value = String.Format("{0}-{1}", r, c)

    ws.DeleteColumn(1, 2)
    ws.PrinterSettings.RepeatColumns = ws.Cells("A:A")
End Using
Third example that also triggers this, editing a file that already exists on disk:
Using dstPackage As ExcelPackage = New ExcelPackage(dstInfo)
                Dim SNRSheet As ExcelWorksheet = CreateSheet(dstPackage, "SNR calcs")
                SNRSheet.PrinterSettings.RepeatColumns = SNRSheet.Cells("A:A") 'Triggers error.
End Using