Solved

Excel XML

Posted on 2011-09-13
9
306 Views
Last Modified: 2012-06-21
Hi all,

I am trying to insert an a logo image on my worksheet which i am creating using XML but it is not working.

img="./images/logo.gif";

"   <Row ss:StyleID=\"Default\">" +
"    <Cell ss:MergeAcross=\"9\">"+"<Data ss:Type=\"String\">" +img + "</Data></Cell>" +
"   </Row>";

Your help is much appreciated.
varvoura
0
Comment
Question by:varvoura
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 36528649
Have you tried creating a worksheet in excel with the image as you want it then saving as XML to see how Excel saves it?
0
 

Author Comment

by:varvoura
ID: 36528661
Hi JulianH,

Yes I have but when you try to save the excel worksheet, it discards the image.

I need to be able to do this in code as described above.

Thanks
0
 
LVL 19

Expert Comment

by:akoster
ID: 36528672
You could take a new worksheet, manually insert an image, and save it as an XLSX document.
Then navigate to the document and change the name by adding the .zip extension to the file.
Extract this zip file to a new folder, and locate drawing1.xml in the folder /xl/drawings

In the worksheet that contains the image, you will notice XML entry
<drawing r:id="rId1"/>

in this case the image is inserted as an object, possibly spanning multiple rows & columns. It's precise location is defined in the drawing1.xml file.
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 36528689
Are you using 2003 or higher? There is a restriction with 2003 being able to do this but as far as I know it can be done with 2007/2010 docs
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:varvoura
ID: 36528735
julianH,

I need the image to work in all versions of excel

akoster,

I inserted an image, saved it as xml , then when I opened it in wordpad, I couldn't find the
<drawing r:id="rId1"/> line you referring to.


any  other suggestions would be appreciated.
thanks
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 36528749
That was the point of my previous post 2003 does not appear to support images in XML.
0
 
LVL 19

Accepted Solution

by:
akoster earned 500 total points
ID: 36535736
Varvoura,

when you save the worksheet as XML file it will not be present because of the limitation of the save to XML format.
for more information, open this microsoft hyperlink.

When you save the worksheet as an .XLSX file however, you can rename this file to .ZIP extension and look up the xml files that it is based on. Those will contain the image.
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 37087215
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now