Editting a XML file in Excel, then exporting it back as XML

Franca, Rafael 0 Reputation points
2023-07-19T17:46:28.0666667+00:00

Is it possible to recover the original XML file after importing it to Excel, even if no changes are made to it?

If I right click the table generated after importing it and then go to XML -> Export... I get the error "Cannot save or export XML data. The XML maps in this workbook are not exportable".

Some Google search suggests that some valid XML files can't be exported by Excel. I may be missing something, since I wasn't able to export even this sample XML below, which I've got from Excel internal help page.

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Root>
  <EmployeeInfo>
    <Name>Jane Winston</Name>
    <Date>2001-01-01</Date>
    <Code>0001</Code>
  </EmployeeInfo>
  <ExpenseItem>
    <Date>2001-01-01</Date>
    <Description>Airfare</Description>
    <Amount>500.34</Amount>
  </ExpenseItem>
  <ExpenseItem>
    <Date>2001-01-01</Date>
    <Description>Hotel</Description>
    <Amount>200</Amount>
  </ExpenseItem>
  <ExpenseItem>
    <Date>2001-01-01</Date>
    <Description>Taxi Fare</Description>
    <Amount>100.00</Amount>
  </ExpenseItem>
  <ExpenseItem>
    <Date>2001-01-01</Date>
    <Description>Long Distance Phone Charges</Description>
    <Amount>57.89</Amount>
  </ExpenseItem>
  <ExpenseItem>
    <Date>2001-01-01</Date>
    <Description>Food</Description>
    <Amount>82.19</Amount>
  </ExpenseItem>
  <ExpenseItem>
    <Date>2001-01-02</Date>
    <Description>Food</Description>
    <Amount>17.89</Amount>
  </ExpenseItem>
  <ExpenseItem>
    <Date>2001-01-02</Date>
    <Description>Personal Items</Description>
    <Amount>32.54</Amount>
  </ExpenseItem>
  <ExpenseItem>
    <Date>2001-01-03</Date>
    <Description>Taxi Fare</Description>
    <Amount>75.00</Amount>
  </ExpenseItem>
  <ExpenseItem>
    <Date>2001-01-03</Date>
    <Description>Food</Description>
    <Amount>36.45</Amount>
  </ExpenseItem>
  <ExpenseItem>
    <Date>2001-01-03</Date>
    <Description>New Suit</Description>
    <Amount>750.00</Amount>
  </ExpenseItem>
</Root>
Microsoft 365 and Office Excel For business Windows
{count} votes

1 answer

Sort by: Most helpful
  1. B santhiswaroop naik 405 Reputation points
    2023-07-19T18:07:06+00:00

    The "Export" button under Developer -> XML in Microsoft Excel is used to export XML data to an XML data file. This feature is designed to export XML data that has been imported into Excel using the "Developer -> XML" functionality or other XML data import methods. It allows users to save the data in an XML format that can be used for further processing or sharing with other applications.

    However, the "Export" button is not meant to export any XML data that was not previously imported into Excel. It does not provide a generic way to export arbitrary XML data to an XML file. Therefore, trying to export XML data that was manually entered or copied into Excel will likely result in an error, as you mentioned.

    In the specific case of the sample XML you provided, it was not imported into Excel using the XML import functionality. It was manually entered as text in the worksheet. Therefore, attempting to export it using the "Export" button will not work, and you will encounter the error.

    If you want to export the sample XML data to an XML file, you will need to use other methods outside of Excel, such as saving the sample XML data directly to a text file with a ".xml" extension using a text editor or a specialized XML editor.

    To summarize, the "Export" button in Excel is intended for exporting previously imported XML data, and it won't work for arbitrary XML data entered manually. If you need to save XML data that was not imported into Excel, you'll have to use other methods for exporting it to an XML file.

    --please don't forget to upvote and Accept as answer if the reply is helpful--


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.