Error : Exporting excel through XSLT

2019-06-07 07:01发布

i'm exporting excel file through xml and xslt and getting this error..when trying to open this file...this is the log file

XML ERROR in Table
REASON: Bad Value
FILE:   C:\Documents and Settings\mayankp\Desktop\PrintCheckList.xls
GROUP:  Row
TAG:    Cell
ATTRIB: Index
VALUE:  0

XML ERROR in Table
REASON: Bad Value
FILE:   C:\Documents and Settings\mayankp\Desktop\PrintCheckList.xls
GROUP:  Row
TAG:    Cell
ATTRIB: Index
VALUE:  1

XML ERROR in Table
REASON: Bad Value
FILE:   C:\Documents and Settings\mayankp\Desktop\PrintCheckList.xls
GROUP:  Row
TAG:    Cell
ATTRIB: Index
VALUE:  2

XML ERROR in Table
REASON: Bad Value
FILE:   C:\Documents and Settings\mayankp\Desktop\PrintCheckList.xls
GROUP:  Row
TAG:    Cell
ATTRIB: Index
VALUE:  0

XML ERROR in Table
REASON: Bad Value
FILE:   C:\Documents and Settings\mayankp\Desktop\PrintCheckList.xls
GROUP:  Row
TAG:    Cell
ATTRIB: Index
VALUE:  1

XML ERROR in Table
REASON: Bad Value
FILE:   C:\Documents and Settings\mayankp\Desktop\PrintCheckList.xls
GROUP:  Row
TAG:    Cell
ATTRIB: Index
VALUE:  2

any help is appreciated.

Edit : see complete XML here

1条回答
2楼-- · 2019-06-07 07:34

The XML sample isn't complete, but looking at it, the issues may lie with your second row

     <Row ss:Height="15.75" ss:StyleID="s62">
        <Cell ss:MergeDown="2" ss:StyleID="m57097196">
           <Data ss:Type="String">S/N</Data>
        </Cell>
        <Cell ss:MergeDown="2" ss:StyleID="m57097216">
           <Data ss:Type="String">PRIORITY</Data>
        </Cell>
        <Cell ss:MergeDown="2" ss:StyleID="m57097076">
           <Data ss:Type="String">ITEM </Data>
        </Cell>
        <Cell ss:MergeAcross="2" ss:StyleID="m57097176">
           <Data ss:Type="String">AUDIT TYPE </Data>
        </Cell>
        <Cell ss:MergeDown="2" ss:StyleID="m57097236">
           <Data ss:Type="String">STATUS </Data>
        </Cell>
        <Cell ss:MergeDown="2" ss:StyleID="m57097280">
           <Data ss:Type="String">REFERENCE </Data>
        </Cell>
        <Cell ss:MergeDown="2" ss:StyleID="m57097056">
           <Data ss:Type="String">AUDIT REMARKS</Data>
        </Cell>
     </Row>

In particular the ss:MergeDown and ss:MergeAcross attributes. If you look at the Microsoft Xml Spreadsheet Reference you will see for ss:MergeAcross it says the following:

Specifies the number of adjacent cells across (right unless in right-to-left mode) from the current cell to merge. As mentioned above, indices must not overlap. If duplicates exist, the behavior is unspecified and the XML Spreadsheet document is considered invalid.

So, you may be getting the error because the following Cell is positioned in column 5, and this overlaps Cell in column 4, which spreads across the following two cells. You need to explicitly set the index of the fifth cell to be in column 7. (Note the use of ss:Index="7" in the fifth cell).

     <Row ss:Height="15.75" ss:StyleID="s62">
        <Cell ss:MergeDown="2" ss:StyleID="m57097196">
           <Data ss:Type="String">S/N</Data>
        </Cell>
        <Cell ss:MergeDown="2" ss:StyleID="m57097216">
           <Data ss:Type="String">PRIORITY</Data>
        </Cell>
        <Cell ss:MergeDown="2" ss:StyleID="m57097076">
           <Data ss:Type="String">ITEM </Data>
        </Cell>
        <Cell ss:MergeAcross="2" ss:StyleID="m57097176">
           <Data ss:Type="String">AUDIT TYPE </Data>
        </Cell>
        <Cell ss:Index="7" ss:MergeDown="2" ss:StyleID="m57097236">
           <Data ss:Type="String">STATUS </Data>
        </Cell>
        <Cell ss:MergeDown="2" ss:StyleID="m57097280">
           <Data ss:Type="String">REFERENCE </Data>
        </Cell>
        <Cell ss:MergeDown="2" ss:StyleID="m57097056">
           <Data ss:Type="String">AUDIT REMARKS</Data>
        </Cell>
     </Row>

Additionallly, because of the use of ss:Mergedown, set to 2 for the cells, this means the next two rows are taken up. Therefore the next Row element in your xml should be changed to explicitly set the index to 5 so as not to overlap.

     <Row ss:Index="5" ss:Height="30">
        <Cell ss:StyleID="s76">
           <Data ss:Type="String">1</Data>
        </Cell>

This should hopefully fix your problems.

查看更多
登录 后发表回答