You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用XSD文件从Excel导出XML失败问题求助

Fixing Your XML Export Issue with Mismatched XSD Structure

Hey there! The problem here is that your current XSD doesn't match the XML structure you want to generate—that's exactly why Excel can't create the XML file when you try to export. Let's break this down and fix it.

Your Desired XML Structure

First, let's recap the valid structure you're aiming for (I added a root element since XML requires exactly one root node—this was missing in your example but is mandatory for valid XML):

<Root>
  <Data>
    <ID>1</ID>
    <Number>21</Number>
    <Number>23</Number>
    <Number>22</Number>
  </Data>
  <Data>
    <ID>2</ID>
    <Number>24</Number>
    <Number>25</Number>
  </Data>
  <Data>
    <ID>3</ID>
    <Number>26</Number>
    <Number>26</Number>
  </Data>
</Root>

The Problem with Your Original XSD

Your existing XSD defines a <Root> element that contains multiple <ID> elements (each with an ID attribute and nested <Numbers> elements)—this structure is completely mismatched with your desired <Data>-centric layout. Excel can't map your spreadsheet columns to this incompatible schema, hence the export failure.

Corrected XSD Matching Your Desired Structure

Here's an XSD that perfectly aligns with the XML you want to generate:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <!-- Root element wrapping all Data nodes -->
  <xs:element name="Root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Data" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <!-- Single ID value per Data entry -->
              <xs:element name="ID" type="xs:string"/>
              <!-- Multiple Number values per Data entry -->
              <xs:element name="Number" type="xs:string" maxOccurs="unbounded"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Quick Tips:

  • If your Excel columns for ID and Number are numeric (not text), swap xs:string with xs:int for stricter type validation.
  • Always ensure your XML has one single root element—this is a non-negotiable rule for valid XML files.

Next Steps:

  1. Replace your existing XSD with this corrected version.
  2. Re-map your Excel columns (ID → <ID>, Number → <Number>) using Developer mode.
  3. Try exporting XML again—it should work smoothly now!

内容的提问来源于stack exchange,提问作者Calyfs0

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:00:40