でExcelのセル幅を使用して、私はXSLT を使用してXMLにXMLを変換する必要が私の入力XMLは次のとおりです。XSLT:左を計算する必要があり、右のXSLT
<sheets>
<Cells>
<rows rowNumber="0">
<columns No="0">
<cell id="A1" cellWidth="152" cellHeight="20" >test</cell>
</columns>
<columns No="1">
<cell id="A2" cellWidth="52" cellHeight="20" >test1</cell>
</columns>
<columns No="2">
<cell id="A3" cellWidth="50" cellHeight="40" >test1</cell>
</columns>
</rows>
<rows rowNumber="1">
<columns No="0">
<cell id="B1" cellWidth="50" cellHeight="20" >test</cell>
</columns>
<columns No="1">
<cell id="B2" cellWidth="50" cellHeight="40" >test1</cell>
</columns>
<columns No="2">
<cell id="B3" cellWidth="51" cellHeight="20" >test2</cell>
</columns>
</rows>
</Cells>
</Sheets>
私の予想出力は次のようになります。
<page>
<line l="0" r="152" t="0" b="20">test</line>
<line l="153" r="204" t="0" b="20">test1</line>
<line l="205" r="254" t="0" b="40">test1</line>
<line l="0" r="50" t="20" b="40">test</line>
<line l="51" r="100" t="20" b="60">test1</line>
<line l="101" r="151" t="40" b="60">test1</line>
</page>
問題は次のとおりです。
幅を使用して左右の値を計算するには、2つのものを維持する必要があります。
1.セルの合計行幅まで
2.セル属性cellWidthから取得しているセル幅
上記の2つのパラメータを使用して、左と右を計算できます。 254
セル幅:セルA3
合計行幅のために上記の例で
だから左= 254から50
および右= 254
同様に、セルの高さ
を使用してトップとボトム値を算出する。しかしその場合には、私がコラム賢いデータを計算する必要があると私はどのように私は、私が試してみました
使用していることを行うことを理解することはできません。
XSLT sum preceding siblings on attributes
How to sum the values of several nodes in XSLT
XSLT: Sum of all previous attributes
私のXSLTコードは次のとおりです。
<xsl:for-each select="columns">
<xsl:variable name="totalWidth" select="sum(preceding-sibling::cell/@cellWidth)"/>
<xsl:variable name="totalHeight" select="sum(preceding-sibling::cell/@cellWidth)"/>
<line>
<xsl:attribute name="l">
<xsl:value-of select="$totalWidth" />
</xsl:attribute>
<xsl:attribute name="r">
<xsl:value-of select="(round(cell/@cellWidth)+$totalWidth)" />
</xsl:attribute>
<xsl:attribute name="t">
<xsl:value-of select="$totalHeight" />
</xsl:attribute>
<xsl:attribute name="b">
<xsl:value-of select="round(cell/@cellHeight)+$totalHeight" />
</xsl:attribute>
<xsl:value-of select="cell" />
</line>
だから、あなたが持っているXSLTコードを共有してください
XSLTで新しくなったのでチェックしてください –