【发布时间】:2016-01-30 02:12:13
【问题描述】:
我有一个如下的excel,它在第5行有标题数据。
编辑:
输入的excel也可能出现如下。数据可能出现在任何列中。必须使用行标题广告名称、UID 和状态来识别数据。它不会改变。
然后将其保存为工作簿xml,如下所示
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Jefferson D</Author>
<LastAuthor>Jefferson D</LastAuthor>
<Created>2015-10-29T17:10:31Z</Created>
<LastSaved>2015-10-29T17:15:02Z</LastSaved>
<Company>*CL</Company>
<Version>12.0</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>22060</WindowHeight>
<WindowWidth>34400</WindowWidth>
<WindowTopX>-20</WindowTopX>
<WindowTopY>-20</WindowTopY>
<Date1904/>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Verdana"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s16">
<Font ss:FontName="Verdana" ss:Bold="1"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="10" x:FullColumns="1"
x:FullRows="1">
<Column ss:AutoFitWidth="0" ss:Width="176.0"/>
<Column ss:AutoFitWidth="0" ss:Width="141.0"/>
<Column ss:AutoFitWidth="0" ss:Width="152.0"/>
<Row>
<Cell ss:Index="2" ss:StyleID="s16"><Data ss:Type="String">Ad Report</Data></Cell>
</Row>
<Row ss:Index="3">
<Cell><Data ss:Type="String">IssueNo: 1</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">IssueName: XXX</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Issue Date: YYY</Data></Cell>
</Row>
<Row ss:StyleID="s16">
<Cell><Data ss:Type="String">Ad Name</Data></Cell>
<Cell><Data ss:Type="String">UID</Data></Cell>
<Cell><Data ss:Type="String">Status</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">WWW</Data></Cell>
<Cell><Data ss:Type="String">0A1</Data></Cell>
<Cell><Data ss:Type="String">active</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">XXX</Data></Cell>
<Cell><Data ss:Type="String">1B2</Data></Cell>
<Cell><Data ss:Type="String">active</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">YYY</Data></Cell>
<Cell><Data ss:Type="String">2C3</Data></Cell>
<Cell><Data ss:Type="String">inactive</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>10</PaperSizeIndex>
<HorizontalResolution>-4</HorizontalResolution>
<VerticalResolution>-4</VerticalResolution>
</Print>
<ShowPageLayoutZoom/>
<PageLayoutZoom>100</PageLayoutZoom>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>13</ActiveRow>
<ActiveCol>2</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
我想使用 XSLT2.0 从 Excel xml 文件中提取一些数据,并希望创建一个新的 xml,如下所示
<adverts>
<advert>
<advertName>WWW</advertName>
<advertNumber>0A1</advertNumber>
<advertStatus>active<advertStatus>
</advert>
<advert>
<advertName>XXX</advertName>
<advertNumber>1B2</advertNumber>
<advertStatus>active<advertStatus>
</advert>
<advert>
<advertName>YYY</advertName>
<advertNumber>2C3</advertNumber>
<advertStatus>inactive<advertStatus>
</advert>
</adverts>
我很困惑,因为这是我第一次处理工作簿 XML。任何指导链接也很重要。
【问题讨论】:
-
您知道
advertName或advertNumber等结果元素的名称,还是需要根据Excel 工作表中的数据构造它们? -
我已经知道标签名称。不需要从excel表中提取。仅提取文本值。
标签: xml excel xslt xslt-2.0 xlsx