Version

Print Titles

This topic outlines the print titles support in the Infragistics Excel Engine and provides a code example demonstrating usage.

The topic is organized as follows:

Introduction

Infragistics Excel Engine allows you to designate a contiguous set of rows and/or columns to be repeated on each printed page as “titles”, mimicking the print titles functionality found in Microsoft Excel.

Print titles are supported by use of one or both of the two properties found in the PrintOptions class of the worksheet – one property for repeated rows, called RowsToRepeatAtTop , and one property for repeated columns called ColumnsToRepeatAtLeft .

Creating Print Titles

Overview

The code snippet below creates a print title area from the top row of the spreadsheet using a workbook with the following properties:

  • Workbook Named: output.xls

  • Worksheet Named: PageTitles

  • Print Titles Area: row 1

Code Example

In C#:

// Create the workbook with one worksheet called PageTitles
Infragistics.Documents.Excel.Workbook workbook = new Infragistics.Documents.Excel.Workbook();
Infragistics.Documents.Excel.Worksheet worksheet = workbook.Worksheets.Add("PageTitles");
// Set the repeating print title range of cells across the first row
RepeatTitleRange rtr = new RepeatTitleRange(0, 0);
// Assign our repeat title range to the RowsToRepeatAtTop property
worksheet.PrintOptions.RowsToRepeatAtTop = rtr;
try
{
    // Save the created workbook
    workbook.Save("output.xls");
    // Open the workbook to display the results
    System.Diagnostics.Process.Start("output.xls");
}
catch
{
    MessageBox.Show("If the workbook is open, please close it before saving.", "Save Error",
        MessageBoxButtons.OK, MessageBoxIcon.Stop);
}

In Visual Basic:

' Create the workbook with one worksheet called PageTitles
Dim workbook As New Infragistics.Documents.Excel.Workbook()
Dim worksheet As Infragistics.Documents.Excel.Worksheet = workbook.Worksheets.Add("PageTitles")
' Set the repeating print title range of cells across the first row
Dim rtr As New RepeatTitleRange(0, 0)
' Assign our repeat title range to the RowsToRepeatAtTop property
worksheet.PrintOptions.RowsToRepeatAtTop = rtr
Try
    ' Save the created workbook
    workbook.Save("output.xls")
    ' Open the workbook to display the results
    System.Diagnostics.Process.Start("output.xls")
Catch
    MessageBox.Show("If the workbook is open, please close it before saving.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.[Stop])
End Try