Image into header

Hi,


Recently, I have tried to put my company logo in header of excel file and I after few hours I realized that I need help :)

I have a web application that generates excel file based on parameters entered by user. Application works fine but I can't resolve this header image problem.

Here are my header and footer settings:

THeaderAndFooter HeadersAndFooters = new THeaderAndFooter();
HeadersAndFooters.AlignMargins = true;
HeadersAndFooters.ScaleWithDoc = true;
HeadersAndFooters.DiffFirstPage = false;
HeadersAndFooters.DiffEvenPages = false;
HeadersAndFooters.DefaultHeader = "&COFERTA&R&G";
HeadersAndFooters.DefaultFooter = "&CStrona &P/&N";
HeadersAndFooters.FirstHeader = "";
HeadersAndFooters.FirstFooter = "";
HeadersAndFooters.EvenHeader = "";
HeadersAndFooters.EvenFooter = "";
xls.SetPageHeaderAndFooter(HeadersAndFooters);

and the code I have been trying to use to put and image into the header:

using (FileStream fs = new FileStream(Server.MapPath("~/Lib/Images/logo.jpg"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
byte[] imgData = new byte[fs.Length];
THeaderOrFooterImageProperties imgProps = new THeaderOrFooterImageProperties();

fs.Read(imgData, 0, imgData.Length);
imgProps.FileName = "logo";
imgProps.Anchor = new THeaderOrFooterAnchor(96, 16);
xls.SetHeaderOrFooterImage(THeaderAndFooterKind.Default, THeaderAndFooterPos.HeaderRight, imgData, TXlsImgType.Jpeg, imgProps);
}

As the file generates fine there is no image in upper right corner... 

Hopefully somebody can help me with that :)

Tomek
Hi,
I've just tried your code with an image here, and the generated file has an image in the upper right corner. 
You can see the result I get here, with basically your code and a random jpg image:
http://tmssoftware.net/public/flexcel/test.xlsx

Some things I can think that might be causing problems:
1) What is the active sheet?  Headers and footers are different for each sheet, so you might be setting the headers in say sheet 3, but looking at it in sheet 1 in Excel

2) The image is kind of small (16 of height). Could it be that the image is there, but when rendered small you can't see it?  If you edit the header in Excel, do you see a [Picture] tag?

3)If you are using xlsx, make sure you have an up to date FlexCel, I am not sure in which version this support was added for xlsx, but it should have been after 5.0.

4)Could it be something wrong with the picture itself?  Maybe it isn't a real jpg even if it has that extension?  Can you try with a different image and see if the problem is still there?

Regards,
  Adrian.