2

I'm using the latest Spreadsheet Gear and C# on .NET 3.5

I'm generating a spreadsheet and adding various formatting to it. One thing I would like to do is add an image to the left header section of my spreadsheet for printing. How do I achieve this?

I have tried:

worksheet.PageSetup.LeftHeader = Image.FromFile("file location");

but that doesn't seem to work. When I look at an example in Excel, I notice that excel sees a headed picture as "&[Picture]", but doesn't specify a file path.

Does anyone know the solution to this?

jdylanmc
  • 829
  • 11
  • 24
  • I'm trying to do the same thing, did you find out how to do this? – Doga Sep 02 '11 at 10:08
  • I created a workaround: My image was essentially fancy text with lots of colors. I came up with 2 ways of embedding the text. 1- make an excel file as an embedded resource with all the header formatting you need and just open that with SSG. 2- save an excel file with all the formatting you need in the xml format and inspect it with something like notepad++ to see what excel is representing the data as. In my case, I needed a navy color and excel was calling it something like `&20&K04-024text` for size 20 navy text. As far as I can tell, it's not possible to put an image in the header. – jdylanmc Sep 02 '11 at 15:20

2 Answers2

3

A little late, but here we go:

You we're right with the first line:

worksheet.PageSetup.LeftHeader = "Filename or URL"

but you missed the second command:

xlsheet.PageSetup.LeftHeader = "&G"

there is the usual problem with different languages. For example, if you'd prefer to use Excel in German this tag becomes ="&I" (for no obvious reason)

You can adjust your image with the usual commands.

g3rv4
  • 19,750
  • 4
  • 36
  • 58
mffap
  • 481
  • 4
  • 11
0

I created a workaround: My image was essentially fancy text with lots of colors. I came up with 2 ways of embedding the text. 1- make an excel file as an embedded resource with all the header formatting you need and just open that with SSG. 2- save an excel file with all the formatting you need in the xml format and inspect it with something like notepad++ to see what excel is representing the data as. In my case, I needed a navy color and excel was calling it something like &20&K04-024text for size 20 navy text. As far as I can tell, it's not possible to put an image in the header.

jdylanmc
  • 829
  • 11
  • 24