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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to know the header height?

Thread ID:

Created:

Updated:

Platform:

Replies:

143944 Apr 11,2019 07:58 AM UTC Apr 11,2019 01:25 PM UTC WPF 1
loading
Tags: XlsIO
Federico Timillero
Asked On April 11, 2019 07:58 AM UTC

Hi to all, I want to insert a customer logo in a worksheet header. Is there a way to automatic resize the image to the headre height? if not, it is possible to know the header heigth?

Thank you in advance.

Federico

Meikanda Nayanar [Syncfusion]
Replied On April 11, 2019 01:25 PM UTC

Hi Federico, 
 
The header height can’t be modified in Microsoft Excel, Syncfusion Excel library (XlsIO) does the same. However, we can modify the top/bottom and header/footer margin based on the image height to fit the image in the header. 
 
We have prepared the sample in which header has been changed based on image height and using header and top margin. The sample can be downloaded from the below link. 
 
Sample Link: 
 
Code snippet: 
              Image image = Image.FromFile(@"../../logo.png"); 
              //Getting the image height in inches 
              double heightInInches = image.Size.Height /(image.VerticalResolution); 
               
              //Set the pagesetup top margin to image height to fit 
              worksheet.PageSetup.TopMargin = heightInInches; 
 
              //Set the pagesetup header margin is 0 
              worksheet.PageSetup.HeaderMargin = 0; 
 
              //Set the image in header 
              worksheet.PageSetup.CenterHeader = "&G"; 
              worksheet.PageSetup.CenterHeaderImage = image; 
 
Please let us know if you have any clarifications. 
 
Regards, 
Meikandan 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon