// Create a pdf file stream using FileStream outputStream = new FileStream("ManageHeadersOnDifferentPages.pdf", FileMode.Create); //create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); Stream fileStream = this.GetResourceStream("xlsx\\MultipleHeaders.xlsx"); workbook.Open(fileStream); IWorksheet worksheet = workbook.Worksheets[0]; IList<RepeatSetting> repeatSettings = new List<RepeatSetting>(); //The title rows of the "B2:F87" is "$2:$2" RepeatSetting repeatSetting = new RepeatSetting { TitleRowStart = 1, TitleRowEnd = 1, Range = worksheet.Range["B2:F87"] }; repeatSettings.Add(repeatSetting); //The title rows of the "B91:F189" is "$91:$91" RepeatSetting repeatSetting2 = new RepeatSetting { TitleRowStart = 88, TitleRowEnd = 88, Range = worksheet.Range["B89:F149"] }; repeatSettings.Add(repeatSetting2); //Create a PrintManager. GrapeCity.Documents.Excel.PrintManager printManager = new GrapeCity.Documents.Excel.PrintManager(); //Get the pagination information of the worksheet. IList<PageInfo> pages = printManager.Paginate(worksheet, null, repeatSettings); //Save the pages into pdf file. printManager.SavePDF(outputStream, pages); // close the pdf stream outputStream.Close();
' Create a pdf file stream Dim outputStream = File.Create("ManageHeadersOnDifferentPages.pdf") ' Create a new Workbook Dim workbook As New Workbook Dim fileStream As Stream = GetResourceStream("MultipleHeaders.xlsx") workbook.Open(fileStream) Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim repeatSettings As IList(Of RepeatSetting) = New List(Of RepeatSetting) 'The title rows of the "B2:F87" is "$2:$2" Dim repeatSetting As New RepeatSetting With { .TitleRowStart = 1, .TitleRowEnd = 1, .Range = worksheet.Range("B2:F87") } repeatSettings.Add(repeatSetting) 'The title rows of the "B91:F189" is "$91:$91" Dim repeatSetting2 As New RepeatSetting With { .TitleRowStart = 88, .TitleRowEnd = 88, .Range = worksheet.Range("B89:F149") } repeatSettings.Add(repeatSetting2) 'Create a PrintManager. Dim printManager As New Excel.PrintManager 'Get the pagination information of the worksheet. Dim pages As IList(Of PageInfo) = printManager.Paginate(worksheet, Nothing, repeatSettings) 'Save the pages into pdf file. printManager.SavePDF(outputStream, pages) ' close the pdf stream outputStream.Close()