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.
Unfortunately, activation email could not send to your email. Please try again.

Add Header and Footer logo images

Thread ID:

Created:

Updated:

Platform:

Replies:

57065 Feb 25,2007 05:47 PM Aug 22,2017 06:10 AM Windows Forms 11
loading
Tags: XlsIO
Administrator [Syncfusion]
Asked On February 25, 2007 05:47 PM

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



Melba Winshia [Syncfusion]
Replied On February 26, 2007 03:52 AM

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

Administrator [Syncfusion]
Replied On February 26, 2007 11:30 AM

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

Melba Winshia [Syncfusion]
Replied On February 27, 2007 01:00 AM

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

Administrator [Syncfusion]
Replied On February 27, 2007 04:58 AM

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();

Melba Winshia [Syncfusion]
Replied On February 28, 2007 07:37 AM

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

Administrator [Syncfusion]
Replied On February 28, 2007 10:02 AM

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

Lan

Melba Winshia [Syncfusion]
Replied On March 1, 2007 04:43 AM

Hi Lan,

Thanks for the update!

Kindly let me know if you have any other questions.

Regards,
Melba

meir rotfleisch
Replied On August 21, 2017 02:27 AM

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

Mohan Chandran [Syncfusion]
Replied On August 21, 2017 06:37 AM

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. 


meir rotfleisch
Replied On August 21, 2017 07:20 AM

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



Mohan Chandran [Syncfusion]
Replied On August 22, 2017 06:10 AM

 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;