Excel and XML -- exporting sheets and lists of lists.

Posted on 2004-08-12
Last Modified: 2008-01-16
My company is using an excel spreadsheet for data capture.  The sheet has complex relationships (lists of lists) and multiple tabs of data within the excel file.  Excel in Office 2003 has the ability to export data to an .xml file, provided an .xsd is used to create a map.  The problem is the (relative) complexity of the data.  The first issue is with the excel sheet tabs; can a repeating element be mapped from each tab, where each tab is an instance of that element?  The second issue is the mapping of “lists of lists”.  

Is it possible to export repeating elements which contain repeating elements?  I’ve been unsuccessful so far, though it doesn’t seem like it should be difficult to do.  This seems to be a simple matter of being able to nest a child XML element under a parent from the EXCEL sheet, but Excel doesn't seem to be able to do that, at least not from the mapping provided.

Any info would help, thanks!
Question by:c4labb
  • 3
  • 2
LVL 26

Expert Comment

ID: 11785947
Since you're using Office 2003, can I suggest using InfoPath rather than Excel?  InfoPath is MUCH better at this than Excel, and is way easier to use--especially with complex data structures.  I've been creating some pretty nifty stuff lately with it.  I give it both thumbs up (leaving my fingers free to type!  ;^)

Mike Sharp

Author Comment

ID: 11786014
Thanks for feedback -- we did entertain using InfoPath.  

However our [internal] clients were familiar with the format of the Excel spreadsheet and were comfortable using it... that we've been pretty much mandated to use the current sheets with major updates baseline on our [tight] timelines.
LVL 26

Expert Comment

ID: 11786344
I assume you've looked at this:

I haven't gone through this myself, but it looked like it might be helpful.

It seems to me that the first task would be to create the Schema that has the structure you want, then map it to the appropriate places.  But if you can't create a schema and map it to Excel the way you want, you may be forced to post-process the XML from the spreadsheet using an XSLT transform to get it into the format you want.  

It's a pity your internal customers won't embrace InfoPath here...It offers some things you just can't get with Excel.  Multiple views are analogous to tabs, and repeating sections and tables are similar to your list of lists.  

Mike Sharp


Author Comment

ID: 11786948
Thanks for the link.  The example they use (and it's all over Microsoft) is a very basic expense report, with one section of one-to-one mapped data and one repeating section.  I'm wondering if multi-level repeating groups are possible at all from Excel.

And the post-processing via XSLT is a given regardless.  Unfortunately, if Excel does not like the structure of the .xsd due to complexity, it will not export to XML at all.  This is even in this case: I created what the final XML should look like, with the nested repeating elements.  I opened the XML with Excel, selecting the "open as XML list" option, which caused Excel to create its own schema.  The data displayed in flattened format in Excel, and it was even mapped for me.  HOWEVER, when I clicked "export" in the data/xml menu... it would not do it!  And this was due to "lists of lists", even when the schema had been created and mapped by Excel itself!

Very frustrating indeed.  Again, thanks for the responses.
LVL 26

Accepted Solution

rdcpro earned 125 total points
ID: 11787723
Oh, that's a problem.  I mean, you can deal with flattened XML very easily in XSLT with Muenchian Grouping, but if Excel won't even create it...

You'll probably have to create your own schema, I think.  It does seem clear that Excel can't handle it automatically.  Even then, it might not work in Excel.  I just ran into a similar issue yesterday with InfoPath; that is, nested repeating elements.  But I created a custom schema, and InfoPath handled it just fine.  Good luck!  

Mike Sharp


Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XSLT Assistance 9 48
VB.Net and XML XSD Files 1 53
c# code 19 69
XML & .net 5 40
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A short film showing how OnPage and Connectwise integration works.

919 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