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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

710 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