I want to export data that are on an xlsx file (pets.xlsx) to xml format.
When I use the Excel GUI, I can save the Sheet1 to XML and get the desired output file.
I can also get the desired result by exporting the data through the Developer Tab in Excel GUI.
Now I want to do this in PowerShell. I used this code that I found here :
$xlXMLSpreadsheet = 46
$Excel = New-Object -Com Excel.Application
$WorkBook = $Excel.Workbooks.Open("d:\pets.xlsx")
$WorkBook.SaveAs("d:\pets.xml", $xlXMLSpreadsheet)
$Excel.Quit()
The problem is that the generated xml file is not the expected result.
Thanks in advance
Amine
Note : I've also posted the problem here to maximize my chances to solve the problem.
xlOpenXMLWorkbook, but I'm not sure that's it.$xlXMLSpreadsheet = 46corresponds to the XML file format you need; rather, it corresponds to an XML Spreadsheet file format, which is why you are not getting the output you desire. You are probably going to have to use an approach similar to this.