Most Valuable Professional


View Jan Karel Pieterse's profile on LinkedIn subscribe to rss feed
Subscribe in a reader

Subscribe to our mailing list

* indicates required
Newsletter Archive

File crashes Excel!!

Save my workbook!
The best tool for salvaging problematic workbooks.

Events


Excel VBA for Financials (Dutch)

Third party tools

Speed up your file

FastExcel
The best tool to optimise your Excel model!

Repair your file

Stellar Phoenix Excel Repair
Best tool to repair corrupt Excel sheets and objects
Home > English site > Articles > XML and Excel > XML in Excel
Deze pagina in het Nederlands

XML and Excel

XML in Excel

Let's get a bit more practical and use Excel to do something with XML files. With Excel 2003/2007/2010/2013 importing XML data is very simple. Unfortunately, the XML facilities are only available in Excel 2007 and up and in the Microsoft Office Professional or ultimate versions of Excel 2003, or when Excel 2003 is bought as a standalone package. When you select File (Office button in Excel 2007 and up), Open from Excel, then you will see xml file types are shown along with the available Excel files:

By default, XML files show when you try to open a file with Excel
Figure 2: The File, Open window of Excel 2007 and up.

Selecting the file test-en.xml causes a small window to appear (see figure 3).

The Open XML selection dialog of Excel
Figure 3: Excel asking what to do with the XML file

By selecting the third option Excel will analyse the structure of the XML file and present the structure in the taskpane (figure 4). Excel does not open the XML file at this moment.

The structure of the xml file shows up in the taskpane
Figure 4, The structure of the xml file shows up in the taskpane

The elements of the XML file can now be tied to cells on the sheet, simply by dragging them from the task pane to a cell in Excel. See Figure 5 and 6.

Dragging an element to an Excel cell
Figure 5: Dragging an element to an Excel cell

Result after dropping the element
Figure 6: Result after dropping the element

By dragging an element which contains multiple other elements (or by selecting multiple elements in the taskpane using control+click or shift+click) all elements are placed next to each other as a list:(see figure 7).

List produced by dragging the "employee" element to the sheet
Figure 7: List produced by dragging the "employee" element to the sheet

Now a template has been defined which can import data from XML files which have the same structure as the one we "opened" in Excel. We can import the data from test_en.xml, simply by pressing the refresh button on the "External Table Data" group of the custom "Table tools, design" tab of the ribbon in Excel 2007 and up, or by clicking the Refresh XML data button on the List toolbar of Excel 2003 (see figure 8 and 9). The data from test_en.xml will be read into our newly created template. See figure 10.

Refresh Data using the ribbon
Figure 8: Refresh Data using the ribbon

Button "Refresh XML data"on the “List” toolbar
Figure 9: Button "Refresh XML data"on the "List" toolbar

Result of importing the data
Figure 10: Result of importing the data

To import a different file into the same structure, use the connection properties dialog, which you can access by clicking the dropdown arrow below the refresh button (see figure 11):

Changing connection properties to Import another XML file into Excel

Figure 11: Changing connection properties to Import another XML file into Excel

After clicking connection properties, click the Details tab on the dialog that shows up and you can hit the browse button to access a different XML file. Or -in Excel 2003- Simply press the "Import XML" button on the List toolbar.


 


Comments

Showing last 8 comments of 192 in total (Show All Comments):

 


Comment by: Jan (4/16/2015 3:08:07 PM)

Hi Jan,

I am looking for solution on below problem:

I have a huge data. I am applying filter on that data and I want to loop into the filtered data to read the one of the column and take sum of the data available in that column.

Please Help.

Thanks.

 


Comment by: Jan Karel Pieterse (4/17/2015 12:45:51 PM)

Hi Jan,

Have you tried inserting a pivottable?

 


Comment by: Grizzle (4/17/2015 4:03:24 PM)

Hello,

I am working with CRM 2011 and have only excel version 2013 on my system. When I try to export the data to excel it will not let me. Is there some sort of connection I need to establish or a compatibility issue?

Thank you

 


Comment by: Jan Karel Pieterse (4/21/2015 8:02:57 AM)

Hi Grizle,

Does it give you an error of some sort?

 


Comment by: Grizzle (4/21/2015 3:25:22 PM)

Nope, no error, it is simply grayed out.

 


Comment by: Jan Karel Pieterse (4/21/2015 3:27:08 PM)

Hi Grizzle,

Is the worksheet protected?
Does the XML validate against the schema?

 


Comment by: When pulling xml data is not coming like a Table (4/22/2015 2:34:45 PM)

Hello, When I am pulling fields from XML source into cells, usually it gives me a table with respected header.

But unfortunately for one of the link it is giving like a blue border boxes with hear option (like, handle).

There is nothing happening, even how many times I used.

Let me know what is exact problem and what are solutions for this.

( I tried deleting and adding. again and again - but no use. )

Help me out of this!

 


Comment by: Jan Karel Pieterse (4/22/2015 3:31:19 PM)

Hi,

I'm not sure why this happens. Does the XML file contain data? Try right-clicking the connected cells and selecting Xml, Refresh.

 


Comments are temporarily disabled. We expect commenting to be re-enabled on August 1st, 2015

For simple Excel-related questions I advise this site: www.eileenslounge.com.

For projects and other questions, please contact me using my contact form.