We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Add Header and Footer logo images

Hi,
V4.4.0.51 & VS2003

I am trying your XlsIO HeaderFooter sample 'HeaderFooter_2003.sln' in:
C:\Program Files\Syncfusion\Essential Studio\4.4.0.51\windows\XlsIO.Windows\Samples\Spreadsheet Property Settings\HeaderFooter\cs

I want to setup two logo images by following code:
Size size=new Size(20,20);

System.Drawing.Bitmap bmp=new System.Drawing.Bitmap(pHeader.StantecLogo);
sheet.PageSetup.LeftHeaderImage=new System.Drawing.Bitmap(bmp,size);
bmp=new System.Drawing.Bitmap(pHeader.ReportLogo);
sheet.PageSetup.RightHeaderImage=new System.Drawing.Bitmap(bmp,size);

But it does not work.

Any idea? could you revise this sample to add two logos in the header?
Thanks,

Lan



11 Replies

MW Melba Winshia Syncfusion Team February 26, 2007 08:52 AM UTC

Hi Lan,

Thanks for your interest in Essential XlsIO.

Could you please use the following code snippet to set the LeftHeaderImage and the RightHeaderImage?

[C#]

//Left Header Image
IPageSetup pageSetup = ( IPageSetup )sheet.PageSetup;
pageSetup.LeftHeaderImage = bmp;
pageSetup.LeftHeader = "&G";

// Right Header Image
pageSetup.RightHeaderImage = image;
pageSetup.RightHeader = "&G";

Please refer the following sample which implements the above said feature:

Header.zip

Kindly let me know if you have any other questions.

Regards,
Melba


AD Administrator Syncfusion Team February 26, 2007 04:30 PM UTC

Hi,
Thanks for your help. Now I can display the logo in header.

I revised your sample to setup:
pageSetup.CenterHeader ="City of Kitchener"+"\r"+
"Network Reports"+"\r";
I want to know how to set 'Network Reports' to size 12 and bold as you can do it in MS MS Excel "File\Page Setup\Header/Footer tab\customize header.."
Please see the attached screen shot 'untitled.JPG'.

Thanks,

Lan


Header0.zip


MW Melba Winshia Syncfusion Team February 27, 2007 06:00 AM UTC

Hi Lan,

You can use the following code snippet to format the word "Network Reports" bold and in font size 12.

[C#]

//To set 'Network Reports' to size 12 and bold
pageSetup.CenterHeader ="City of Kitchener"+"\r"+@"&24&""Arial,bold""Network Reports"+"\r";

Here is the modified sample as per your requirements:

header.zip

Kindly take a look at the sample above and let me know if you have any other questions.

Regards,
Melba


AD Administrator Syncfusion Team February 27, 2007 09:58 AM UTC

There is also such line in Release notes:
· IHFEngine interface has been added to create/edit strings required by header/footer...
Using this object you can work with header/footer without knowing a lot about MS Excel header/footer string format.

IHFEngine hfEngine = book.CreateHFEngine();
hfEngine.Text = "ArialRegular ItalicBold";

IFont font = book.CreateFont();
font.FontName = "Arial";
hfEngine.SetFont( 0, 12, font );

font = book.CreateFont();
font.FontName = "Arial";
font.Italic = true;
font.Bold = true;
hfEngine.SetFont( 13, 18, font );

pageSetup.CenterHeader = hfEngine.GetHeaderFooterString();


MW Melba Winshia Syncfusion Team February 28, 2007 12:37 PM UTC

Hi,

Yes, we can also format the header/footer by using IHFEngine interface. Please refer the following sample which implements the above said feature

header.zip

Kindly let me know if you have any other questions.

Regards,
Melba


AD Administrator Syncfusion Team February 28, 2007 03:02 PM UTC

Hi guys,
Thank you very much for help. I like the IHFEngine interface method better.

Lan


MW Melba Winshia Syncfusion Team March 1, 2007 09:43 AM UTC

Hi Lan,

Thanks for the update!

Kindly let me know if you have any other questions.

Regards,
Melba


MR meir rotfleisch replied to Administrator August 21, 2017 06:27 AM UTC

There is also such line in Release notes:
· IHFEngine interface has been added to create/edit strings required by header/footer...
Using this object you can work with header/footer without knowing a lot about MS Excel header/footer string format.

IHFEngine hfEngine = book.CreateHFEngine();
hfEngine.Text = "ArialRegular ItalicBold";

IFont font = book.CreateFont();
font.FontName = "Arial";
hfEngine.SetFont( 0, 12, font );

font = book.CreateFont();
font.FontName = "Arial";
font.Italic = true;
font.Bold = true;
hfEngine.SetFont( 13, 18, font );

pageSetup.CenterHeader = hfEngine.GetHeaderFooterString();

Hi

I attempted to implement this code for 2 lines of my header but the full header always ends up only as the second part of the font definition. (size 12 etc)


 int line1 = System.Web.HttpContext.GetGlobalResourceObject("Excel", "CenterHeader").ToString().Length;

        int line2 = System.Web.HttpContext.GetGlobalResourceObject("Excel", "CHeader").ToString().Length;

         

        IHFEngine hfEngine = workbook.CreateHFEngine();

       

        hfEngine.Text = cheader;


        IFont font = workbook.CreateFont();

        font.FontName = "Arial";

        font.Size =18;

        font.Bold = true;

        font.Underline = Syncfusion.XlsIO.ExcelUnderline.Single;


        hfEngine.SetFont(0, line1, font);


        font.FontName = "Arial";

        font.Bold = false;

        font.Size = 12;

        font.Underline =  Syncfusion.XlsIO.ExcelUnderline.None;

        hfEngine.SetFont(line1+1,cheader.Length, font);

     


        worksheet.PageSetup.CenterHeader = hfEngine.GetHeaderFooterString();


Attached is the resx file the texts are being taken from


Regards

Meir



Attachment: Excel_2fa638f2.rar


MC Mohan Chandran Syncfusion Team August 21, 2017 10:37 AM UTC

Hi Meir, 
 
We have analyzed your code snippet and found that this a usage level issue. You have to create a new font when you need to apply different font style. Please refer the release notes in which we have created a new font while applying another font style. We have prepared a sample with the modified code to achieve your requirement which can be downloaded from the following link . 
 
 
Please let us know if you have any other queries. 
 
Regards, 
Mohan Chandran. 



MR meir rotfleisch August 21, 2017 11:20 AM UTC

Hi

Thanks this now works. My only other issue with header/footer is how to define a  Header/Footer for page 1 and no header for the other pages.


Looking forward to your swift response


Regards


Meir Rotfleisch




MC Mohan Chandran Syncfusion Team August 22, 2017 10:10 AM UTC

 Hi Meir, 
 
Currently, we don’t have support to set the header and footer only in first page. However, we have added it to our feature request list and it will be implemented in any of our upcoming releases. 
 
Please let us know if you have any other queries. 
 
Regards, 
Mohan Chandran. 


Loader.
Live Chat Icon For mobile
Up arrow icon