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