aspose question.zip (191.7 KB)
In attached input file of type excel(Source template) we are considering row no 8 to 16 as footer of report.If these section is going to print in next page then i dont want to repeat header in next page, else repeat header with if data is going into next pages…
How we are going to achieve this? any suggestion.
Hi,
Please find the attached console AppAsposeRepeatedHeader.zip (5.5 MB)
. To convert “37375447-d6eb-4a37-b983-058ca06fd71c.xlsx” to pdf we are using below code for repeating the header in each page in pdf.
excelworkbook.Worksheets[0].PageSetup.PrintTitleRows = “$1:$5”;The issue is that when the page is having only the footer it repeats the header as well.The converted file “headerissue.pdf” has both header and footer in second page but only footer is expected. (Footer is from text “NOTE” in the second page)
@PolarisAP,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.
This issue has been logged as
CELLSNET-46958 - Repeated header when converting excel template to pdf
@PolarisAP,
There is no way to achieve this. Because your designed footer are cell contents, when it goes to next page, your designed header will repeat. You can check it by saving it to xlsx file before saving to pdf, you will find that the generated xlsx file also repeats header on the second page in Microsoft Excel.
Hi Team,
I found solution .I have configure the header and footer length . Below code is working for me.
private void SetRepeatHeader()
{
if (true)
{
var printOptions = new ImageOrPrintOptions();
var pageBreaks = excelworkbook.Worksheets[0].GetPrintingPageBreaks(printOptions);
var i = 0;
while (i < pageBreaks.Length )
{
if (i == pageBreaks.Length) break;
if (i == 0) { i++; continue; }
if (!(pageBreaks[i].EndRow - pageBreaks[i].StartRow == 15 || pageBreaks[i].EndRow - pageBreaks[i].StartRow < 15))
{
InsertHeaderRows(excelworkbook.Worksheets[0].Cells, pageBreaks[i].StartRow);
pageBreaks = excelworkbook.Worksheets[0].GetPrintingPageBreaks(printOptions);
}
i++;
}
}
}
public void InsertHeaderRows(Cells cells, int startRow)
{
cells.InsertRows(startRow, 5);
cells.CopyRows(cells, 0, startRow,5 );
}
@PolarisAP,
No, header rows can not be hidden. However, you can copy rows at page breaks. But take care that, after adding copy rows, the follow-up page beaks will be changed.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.