Repeat header row in subsequent pages - Excel to PDF

I have multiple grids inside PDF file. For example, if single grid details exceeds more than one page, at that time I need to show grid header in subsequent pages as well. I am using Aspose Cells product and also I am converting the Excel file to PDF format. Could you please help me to achieve this feature?

Also I have noticed font thickness is too high in PDF file if we apply boldness, for example grid header when compared with Excel file.

Grid Header 1: Emp Code, Empoyee Name, Empoyee Age, Empoyee Name, Empoyee Department, Empoyee Salary, Empoyee Status

Grid Header 2: Contract Emp Code, Contract Emp Name, Contract Emp Age, Contract Emp Department, Contract Emp Salary, Contract Emp Status

Sample PDF File:
testfile-repeatheaders.pdf (88.1 KB)

Sample Project:
Aspose.Cells.Sample.zip (5.8 MB)

@SenthilRG27,

I have evaluated your PDF file a bit. For your information, there is a built-in feature/option of MS Excel for Page Setup that can used to print title rows, see the document example for your reference. You may use this feature, see the sample line of code that can be embedded before rendering to PDF:
e.g
Sample code:

............
// Obtaining the reference of the PageSetup of the worksheet
Aspose.Cells.PageSetup pageSetup = worksheet.PageSetup;

// Defining row 1  as title rows always.
pageSetup.PrintTitleRows = "$1:$1";
..........

The core thing is you need to place/split Table-2 (with its data) or any other sub-subsequent tables on different sheet(s). For example, first sheet will only have Table-1, second sheet will have Table-2. Third sheet will have Table-3 and so on. You got to accommodate this in your code by yourselves. This way, you will set the MS Excel’s option “Rows to repeat at top” of each sheet’s PageSetup differently via Aspose.Cells APIs (see the above code segment for reference).

Hope, this helps a bit.

@Amjad_Sahi

We are downloading reports in both Excel and PDF formats. I have written code for Excel, which contains both the tables in single worksheet and convert that Excel file to PDF file by using three lines of code. I didn’t write separate code for PDF file generation. Based on your inputs, I need to write separate code for generating Excel file and convert it to PDF file. Is there any straight forward solutions available to generate PDF file with single Excel sheet?

Also please check font thickness issue in PDF file.

@SenthilRG27,

No there is no straight forward solution to this task even in MS Excel. You got to devise as suggested. If you find any other simple way to do it in MS Excel, let us know with details and we can check it. Please note, the PDF is generated based on Excel workbook, so you have to use certain options (e.g Page Setup) to accomplish your custom needs. Sure, you need to write separate code for generating Excel file and convert it to PDF file.

We think it is not an issue, Aspose.Cells renders the header row ok same as what MS Excel renders when you save the Excel file to PDF. If you have issue with boldness, you just set the boldness option off in code and just extend the font size a bit.

@Amjad_Sahi

I am able to achieve repeat header in multiple pages in PDF file by following your approach. I have attached PDF file and sample solution for your reference. I have created two tables and placed in two different worksheets. Is it possible to place part of second table contents in 3rd page itself instead of starting from 4th page in attached PDF file because first table contents are completed in 3rd page mid way and also we are having empty space in 3rd page.

SamplePDFReport.pdf (91.0 KB)

Aspose.Cells.Sample.zip (5.8 MB)

@SenthilRG27,

Well, we devised an approach to split each table in different sheet, why? The reason is we got to repeat certain row(s) as header when rendering each table with its contents. If you can live with skipping certain row to be repeated (as header) at top, you’d better place all the tables in single worksheet, this would not insert any space b/w tables for sure. I am afraid, such space in certain pages would be obvious and there may not be any better way to cope with it (considering the fact you need certain rows to be repeated as header for certain tables).

I guess removing spaces on the pages is possible using Aspose.PDF API (although shifting tables may not be straight forward thing). So, once the PDF file is generated, you may further modify the PDF contents via Aspose.PDF API. Maybe you could post a new thread in Aspose.PDF forum with all the details for the task.

@Amjad_Sahi
We have procured license for Aspose Cells Product Family only. I thing I can not use Aspose PDF API with that license and also I can not ask my client to procure PDF license for this feature alone.

@SenthilRG27,
Yes, you are right that with Aspose.Cells license, you cannot use Aspose.PDF and a separate license is required for it.

@Amjad_Sahi, @ahsaniqbalsidiqui,

I have opened a new thread to achieve above requirement with Aspose PDF API after converting Excel to PDF by using Aspose Cells API. Please help me to resolve the issue.

@SenthilRG27,

We can only help you here for technical queries and issues regarding Aspose.Cells APIs. Regarding your requirements using Aspose.PDF API, please be patient as our Aspose.PDF team will evaluate it and help you in your new thread in Aspose.PDF forum.