473,322 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

C# / Excel Inserting Image At Header, How?

catatonicalvin
I'm working right now C# to Excel.
How do i insert image at left and right header, through c# code?
Please refer to code:

Expand|Select|Wrap|Line Numbers
  1. Excel.Application xl = new Excel.ApplicationClass();             
  2. Excel.Workbook wb = xl.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);           
  3. Excel.Worksheet ws = (Excel.Worksheet)wb.ActiveSheet;
  4.  
  5. ws.PageSetup.LeftHeaderPicture.Filename = Path.GetFullPath("1.png");     
  6. ws.PageSetup.RightHeaderPicture.Filename = Path.GetFullPath("2.png");
  7.  
This code doesn't show image. Help please.
Oct 3 '08 #1

✓ answered by Gayazh

your code is right..

After you add image, you have to have this code for view it..

mySheet.PageSetup.CenterHeader = "&G";

If you want get that image in to middle of the page, use this..

mySheet.PageSetup.CenterHeader = "&C\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n&G";

This works..

2 12053
your code is right..

After you add image, you have to have this code for view it..

mySheet.PageSetup.CenterHeader = "&G";

If you want get that image in to middle of the page, use this..

mySheet.PageSetup.CenterHeader = "&C\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n&G";

This works..
Oct 13 '10 #2
Thanks for your feedback. Finally, I got reply after 2 years. :)
Oct 13 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Stan | last post by:
In the old days of VB6, an Excel chart image could be pasted into a picture box with Clipboard using the following commands. xlApp.ActiveChart.ChartArea.Copy Picture1.Picture =...
7
by: Andrew Poulos | last post by:
I'm using the following code to create a small table with one column and two rows. An image goes into the first cell. //create table var t = document.createElement("TABLE"); t.style.position =...
3
by: John Baker | last post by:
Hi: I have a slight problem. I have a form that I designed without a header, and I subsequently decided a header was required. In design I went to View/Page header footer, and it appeared nice...
1
by: Jason | last post by:
For some reason, most but not all reports printing from an access application our client is using will not print any images on the reports or forms. One report will print the image and data...
2
by: guoqi zheng | last post by:
dear sir, I am using itextShap for pdf generation. I know I can insert image into it, I can add header to it as well. However, I can not add an image as a header. Does any one has experience...
3
by: Daves | last post by:
hi, exporting GridView data to Excel is no problem but in the first data row I would like to put some descriptive information for the table. I cannot see any way to add this directly to the...
1
by: joy | last post by:
Hi. I have a datagrid which displays images in cells. User wants to download the grid data as excel file. Now, if datagrid contains only data, it is fine. But if it contains some images, images...
0
by: eBob.com | last post by:
Here's how I insert and size pictures in an Excel spreadsheet which I create via a VB.NET program (commentary follows): 'add thumb nail objSheet.Rows(XLRow.ToString).rowheight =...
1
by: rizwanrajput | last post by:
I am using C# 2.0 and developing an application to convert a PDF file into HTML, Word, Excel and Image (GIF,JPEG,PNG,TIFF). Is there any free library / class available for that?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.