在Excel中映射多个XML元素

时间:2014-04-02 01:37:46

标签: xml excel xsd

我正在尝试将XML文件映射到Excel工作表以创建报告。将有多个XML文件全部导入到单个Excel工作表中。

我创建了一个XSD文件,我可以将其映射到Excel文件并导入数据,但这些值未在Excel工作表中正确映射。

以下是XML示例文件,所有文件都共享此结构。

<?xml version="1.0" encoding="utf-8"?>
<Task>
    <ID>13568133</ID>
    <Title>Sample</Title>
    <Description />
    <Status>InProgress</Status>
    <CreatedOn>Thu, 20 Feb 2014 15:41:21 GMT</CreatedOn>
    <Start>Tue, 25 Feb 2014 00:00:00 GMT</Start>
    <End />
    <CreatedBy>Joe Smith</CreatedBy>
    <Assignees>
        <Assignee>Bob Harry</Assignee>
    </Assignees>
    <Comments>
        <CreatedOn>Fri, 21 Feb 2014 15:28:56 GMT</CreatedOn>
        <CreatedBy>Person A</CreatedBy>
        <Comment>
  - Will they also be leading the P2P process during due diligence?
  - Robert has expressed concern around who will manage the P2P process
  - Robert to review IT Analyst Deck shared with his team earlier this month on 2/19</Comment>
        <CreatedOn>Wed, 05 Mar 2014 23:11:46 GMT</CreatedOn>
        <CreatedBy>Person B</CreatedBy>
        <Comment>- Complete initial onsite due diligence 3/3 to 3/5
- Mapped out current state process flows and initial validation confirmed by client
- Client may want to go live ahead of having CMD solution in place</Comment>
        <CreatedOn>Fri, 07 Mar 2014 22:17:31 GMT</CreatedOn>
        <CreatedBy>Person B</CreatedBy>
        <Comment>- Future state process flows in progress (15% completed)
- Tim  to contact client with clarification questions for future state
- Tim  to discuss process with client.</Comment>
        <CreatedOn>Tue, 11 Mar 2014 14:29:05 GMT</CreatedOn>
        <CreatedBy>Person B</CreatedBy>
        <Comment>- Future state process flows in progress (60% completed)
- Reviewed future state flows with the team on 2014-03-10, a number of questions resulted from the discussion and Tim will contact the client for clarification
- I sent my list of questions for the client on 2014-03-10</Comment>
        <CreatedOn>Thu, 13 Mar 2014 17:38:41 GMT</CreatedOn>
        <CreatedBy>Person B</CreatedBy>
        <Comment>Current state process maps sent to Tim for validation of process, future state process maps in progress (70% completed)</Comment>
        <CreatedOn>Thu, 20 Mar 2014 17:57:55 GMT</CreatedOn>
        <CreatedBy>Person B</CreatedBy>
        <Comment>Future state process maps in progress, 85% completed. Future state process maps continue to be validated and refined with the team.</Comment>
    </Comments>
    <Attachments />
</Task>

问题是每个评论及其CreatedOn和CreatedBy都在一个评论栏中。

我能想到的XSD是 -

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element nillable="true" name="Task">
        <xsd:complexType>
            <xsd:sequence minOccurs="0">
                <xsd:element minOccurs="0" nillable="true" type="xsd:string" name="Title" form="unqualified"></xsd:element>
                <xsd:element minOccurs="0" nillable="true" type="xsd:string" name="Description" form="unqualified"></xsd:element>
                <xsd:element minOccurs="0" nillable="true" type="xsd:string" name="Status" form="unqualified"></xsd:element>
                <xsd:element minOccurs="0" nillable="true" type="xsd:string" name="Assignees" form="unqualified"></xsd:element>
                <xsd:element minOccurs="0" nillable="true" type="xsd:string" name="Start" form="unqualified"></xsd:element>
                <xsd:element minOccurs="0" nillable="true" type="xsd:string" name="End" form="unqualified"></xsd:element>
            <xsd:element minOccurs="0" maxOccurs="unbounded" nillable="true" name="Comments" form="unqualified">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element maxOccurs="unbounded" type="xsd:string" name="CreatedOn"></xsd:element>
                    <xsd:element maxOccurs="unbounded" type="xsd:string" name="CreatedBy"></xsd:element>
                    <xsd:element maxOccurs="unbounded" type="xsd:string" name="Comment"></xsd:element>
                </xsd:sequence>
            </xsd:complexType>
            </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

然后麻烦的是Excel将Comment,CreatedOn和CreatedBy映射到不同的行,如屏幕截图所示。我怎样才能使所有这些值都在同一行?

http://i.stack.imgur.com/VMXJ0.png

谢谢! 乔

0 个答案:

没有答案