Avatar of StampIT
StampITFlag for United States of America

asked on 

Import XML file into Excel

Attached is a XML file and an Excel spreadsheet after I have imported this XML into it. Is it possible to rearrange the resulting spreadsheet so that the columns are Session#, SourceHost, SourcePath, StartTime, etc with the corressponding values listed by session #? Can this be done via the XML import process into Excel Or is VBA code necessary? Either way I would appreciate assistance. The current format is not manageable. Thanks.
BackUpJob1349.xml
Book3.xlsx
Visual Basic ClassicMicrosoft Excel

Avatar of undefined
Last Comment
StampIT
Avatar of gbanik
gbanik
Flag of India image

Use an XML parser to parse through the XML file and populate the Excel file. There may not be a straight forward way of achieving this. Use the Microsoft XML Library to do so.

Add it as reference in your project
http://msdn.microsoft.com/en-us/library/ms763701(VS.85).aspx

Check this to parse your data
http://msdn.microsoft.com/en-us/library/aa163921(office.10).aspx
Avatar of Bruce Cadiz
Bruce Cadiz
Flag of United States of America image

StampIT,

Here's a different approach by replacing your XML tags with HTML then opening in Excel.
Note: It will open the XML file and replace listed text string / tags with HTML tags then open in Excel. Seemed like the simplest approach since your XML was similarly structured to an HTML table.

Bruce ee-Q26615394.xls
Avatar of StampIT
StampIT
Flag of United States of America image

ASKER

Thanks for the replies. Both of these are way over my head. I thought there might be a simpler way of performing this task.
Bruce: I ran your code with the file I had but it resulted in data in the first row in a language I did not understand. I probably did something wrong.
If I can I should probably withdraw the question.
Avatar of gbanik
gbanik
Flag of India image

StampIT as I mentioned in my comment, there might not be a simpler way. But actually less difficult than u are thinking. This method is a tried and tested way and u can definitely give it a try.
I am confident about the direction.
Avatar of Bruce Cadiz
Bruce Cadiz
Flag of United States of America image

StampIT,

Here is your sample XML file and I've modified the Excel file to save the output in the same directory. It should do exactly what you have asked.

Save them to a folder that you have read/write access to. Then open the Excel file and hit the button to Select the XML File. You are running Windows aren't you? What version of Excel do you have?

Bruce ee-Example.zip
Avatar of StampIT
StampIT
Flag of United States of America image

ASKER

Bruce,
      I am running Windows Vista and Excel 2007. Thanks
ASKER CERTIFIED SOLUTION
Avatar of Bruce Cadiz
Bruce Cadiz
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of StampIT
StampIT
Flag of United States of America image

ASKER

Works exactly how I want it to.
Avatar of Bruce Cadiz
Bruce Cadiz
Flag of United States of America image

StampIT,

Thanks. I believe the suggestions by gbanik regarding the XML parser is something you should look at. While as he stated it may seem complicated, if you were to eventually incorporate it, you would have more functionality / flexibility in the long run, especially if your XML data structures change in the future.

Bruce
Avatar of StampIT
StampIT
Flag of United States of America image

ASKER

Bruce,
      Thanks. I will keep that in mind.
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo