[]
        
(Showing Draft Content)

Configure Columns to Repeat at Left and Right

You can configure columns in a worksheet in order to repeat them at the left by using the PrintTitleColumns property and at the right by using the PrintTailColumns property of the IPageSetup interface.

This feature is useful especially when you're using GcExcel .NET to create reports wherein you want to repeat specific title columns and tail columns in the exported file. With support for repeating specific columns at the left and right side of the page; it becomes much easier and quicker to handle and visualize spreadsheets containing large number of columns.

While exporting a spreadsheet with repeating columns to a PDF file, the tail columns will be exported only when its index is larger than the page's last column's index. Otherwise, the tail column is ignored. For instance, if the Print Area is "A1:J200" and the right repeating column is "$I:$J"; it will print "$I:$J" repeatedly on each page. However, if users set the right repeating column to "$K:$L", then it will not print "$K:$L" (because the column index is larger than print area).

Refer to the following example code in order to configure columns to repeat at the right.

// Initialize workbook
Workbook workbook = new Workbook();
        
// Fetch default worksheet 
IWorksheet worksheet = workbook.Worksheets[0];

// Populating cells in worksheet
var range = worksheet.Range["A1:J200"];
for (int i = 0; i < 200; i++)
    for (int j = 0; j < 8; j++)
    {
        range.Cells[i, j].Value = i.ToString();
        range.Cells[i, 8].Value = "Col I";
        range.Cells[i, 9].Value = "Col J";
    }

// Repeat Columns from I to J at the right of each page while saving PDF
worksheet.PageSetup.PrintTailColumns = "$I:$J";

// Saving workbook to PDF
workbook.Save(@"ConfigureTailColumns.pdf", SaveFileFormat.Pdf);

Refer to the following example code in order to configure columns to repeat at the left.

//Set columns to repeat at left
worksheet.PageSetup.PrintTitleColumns = "$D:$G";