Hi
I found subj in the version 7.0.4.0
The reason is simple.
My Excel uses the '\r' symbol for line separate in the headers. I'm not sure is it regional settings, or all Excel versions makes so.
Also I found workaround, I changed the '\r' symbol to the '\n' symbol in all headers and footers.
Call sample
Workbook workBook = new Workbook( "Book1.xlsx" );
FixHeaderFooter( workBook );
workBook.Save( "Book1.pdf", SaveFormat.Pdf );
Fix method
public static void FixHeaderFooter( Workbook workBook )
{
foreach ( Worksheet worksheet in workBook.Worksheets )
{
PageSetup pageSetup = worksheet.PageSetup;
for( int index = 0; index < 3; index++ )
{
string headerFooter;
string fixedHeaderFooter;
headerFooter = pageSetup.GetHeader( index );
if ( !string.IsNullOrEmpty( headerFooter ) )
{
fixedHeaderFooter = FixHeaderFooter( headerFooter );
pageSetup.SetHeader( index, fixedHeaderFooter );
}
headerFooter = pageSetup.GetEvenHeader( index );
if ( !string.IsNullOrEmpty( headerFooter ) )
{
fixedHeaderFooter = FixHeaderFooter( headerFooter );
pageSetup.SetEvenHeader( index, fixedHeaderFooter );
}
headerFooter = pageSetup.GetFirstPageHeader( index );
if ( !string.IsNullOrEmpty( headerFooter ) )
{
fixedHeaderFooter = FixHeaderFooter( headerFooter );
pageSetup.SetFirstPageHeader( index, fixedHeaderFooter );
}
headerFooter = pageSetup.GetFooter( index );
if ( !string.IsNullOrEmpty( headerFooter ) )
{
fixedHeaderFooter = FixHeaderFooter( headerFooter );
pageSetup.SetFooter( index, fixedHeaderFooter );
}
headerFooter = pageSetup.GetEvenFooter( index );
if ( !string.IsNullOrEmpty( headerFooter ) )
{
fixedHeaderFooter = FixHeaderFooter( headerFooter );
pageSetup.SetEvenFooter( index, fixedHeaderFooter );
}
headerFooter = pageSetup.GetFirstPageFooter( index );
if ( !string.IsNullOrEmpty( headerFooter ) )
{
fixedHeaderFooter = FixHeaderFooter( headerFooter );
pageSetup.SetFirstPageFooter( index, fixedHeaderFooter );
}
}
}
}
private static string FixHeaderFooter( string value )
{
string fixedHeaderFooter = value.Replace( '\r', '\n' );
return fixedHeaderFooter;
}
I'm not sure than this workaround is absolutely correct.
I descried that '\n'symbol still present in line as a space, so result is slightly different beside the excel-native result.
But it's simply works.
Regards Alex.