How to insert a .tiff image in an existing excell sheet particular cell using OpenXML

May 18, 2011 at 10:44 AM

Hi,

Can anyone help me to insert a picture in an existing excel sheet in particular cell using OpenXML and ASP.Net.

My Scenario:

1) I have an excel file caled "E_Daily_Report.xlsx" with sheet name "Daily Report". And have a image file named "E_Image.tiff" (Image is in tiff format).

2) Now i want to insert that E_Image.tiff image file into E_Daily_Report.xlsx  excel file in Range O24:W140.

3) After that i want to convert new excel file (excel with tiff image) convert to .pdf file and show in a page. 

I spend all most 1 and half day but no luck. Please help me asap. This is my project requirement.

Thanks in advance.

Ckandan

Coordinator
May 19, 2011 at 3:43 PM

To know how to do anything with OpenXML just use MS OpenXML SDK 2.0 Productivity Tool. Create a file as you have it just before inserting the image. Add the image to the file and save it as another file. Finally compare the two with the tool.

For more information:

http://www.ecma-international.org/publications/standards/Ecma-376.htm

http://social.msdn.microsoft.com/forums/en-US/oxmlsdk/threads/

To convert the file to PDF you need an Excel viewer and use it to "print" to a PDF file or use a third party component that allows you to create Excel files as well as saving as PDF.

May 20, 2011 at 2:21 PM

Hi mdeleon,

Thanks for quick reply.

I followed your instructions but no luck.

Firstly I will take my original .xlsx file after that insert the tiff image file and save as different file name & compare 2 file with MS OpenXML SDK 2.0 Productivity Tool and copy the change code and paste into my application but nothing will change the application will given an error out of index.

I you ask me to send to you my sample project & excel & tiff file i will send you. That will help you to get the problem. If yes please send me your email id.

My email id is : deychandan@hotmail.com

Thanks

Chandan

Coordinator
May 20, 2011 at 3:03 PM

Use the tool to validate the file, it will give you a rough idea of what's wrong. Also use the tool to compare the file you create with your program and the good file with the image.

I know it can be frustrating to work with OpenXML (that's one of the reasons I started this project in the first place) but I can't do your homework for you, I barely have time to work on this project.