0
votes

I found this article: How can you programmatically import XML data into an Excel file? which shows how to import an XML file into Excel.

My question is how do I import multiple XML files into multiple sheets in one workbook?

The "OpenXML()" method appears to relate to the Workbooks collection only, and creates a new Workbook...

Thanks

2
Create a new sheet, switch to it, run the import again.Murray Foxcroft

2 Answers

0
votes

Use XmlMaps instead of OpenXML and then create new sheets:

Initialize Excel interop 

loop... 

{
    Excel.Worksheet newWorksheet;
    newWorksheet = (Excel.Worksheet)Globals.ThisWorkbook.Worksheets.Add();
    newWorksheet.Select();

    ' Run import code 
}
0
votes

We are using EPPlus.dll to generate Excel file. Using EPPlus.dll you can write Excel file in native format.

Following URL will definetly help you to wirte Excel file. But you have to write logic to read XML file and put in Excel workbook.

http://www.jimmycollins.org/blog/?p=547

https://epplus.codeplex.com/