abap2xlsx/ZA2X/XSLT/ZEXCEL_TR_SHEET.slnk
StefanSchmoecker 020637fa12 Corrected issue #355 ( writer not writing strings with leading blanks )
Added Marcus von Cube's addition that allows to write very large files by using a transformation instead of ixml-handling in the string
2015-02-12 22:28:29 +01:00

310 lines
18 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<XSLT XSLTDESC="ZEXCEL_TR_SHEET" DEVCLASS="$TMP" LANGU="E" DESCRIPT="ZEXCEL Simple transformation for Sheet#.xml">
<source>&lt;?sap.transform simple?&gt;
&lt;tt:transform xmlns:tt=&quot;http://www.sap.com/transformation-templates&quot;
xmlns:r=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships&quot;&gt;
&lt;tt:root name=&quot;WORKSHEET&quot;/&gt;
&lt;tt:root name=&quot;CELLS&quot;/&gt;
&lt;tt:root name=&quot;WRITER&quot;/&gt;
&lt;tt:variable name=&quot;owriter&quot; ref-type=&quot;ZCL_EXCEL_WRITER_HUGE_FILE&quot;/&gt;
&lt;tt:template&gt;
&lt;tt:assign ref=&quot;WRITER&quot; to-var=&quot;owriter&quot;/&gt;
&lt;worksheet xmlns=&quot;http://schemas.openxmlformats.org/spreadsheetml/2006/main&quot;
xmlns:r=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships&quot;
xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
xmlns:x14ac=&quot;http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac&quot;
mc:Ignorable=&quot;x14ac&quot;&gt;
&lt;tt:namespace name=&quot;r&quot; /&gt;
&lt;tt:namespace name=&quot;mc&quot; /&gt;
&lt;tt:namespace name=&quot;x14ac&quot; /&gt;
&lt;sheetPr&gt;
&lt;tt:cond check=&quot;not-initial(WORKSHEET.TABCOLOR)&quot;&gt;
&lt;tabColor&gt;
&lt;tt:attribute name=&quot;rgb&quot; value-ref=&quot;WORKSHEET.TABCOLOR&quot; /&gt;
&lt;/tabColor&gt;
&lt;/tt:cond&gt;
&lt;outlinePr&gt;
&lt;tt:attribute name=&quot;summaryRight&quot; value-ref=&quot;WORKSHEET.SUMMARYRIGHT&quot; /&gt;
&lt;tt:attribute name=&quot;summaryBelow&quot; value-ref=&quot;WORKSHEET.SUMMARYBELOW&quot; /&gt;
&lt;/outlinePr&gt;
&lt;/sheetPr&gt;
&lt;tt:cond check=&quot;not-initial(WORKSHEET.FITTOPAGE)&quot;&gt;
&lt;pageSetupPr&gt;
&lt;tt:attribute name=&quot;fitToPage&quot; value-ref=&quot;WORKSHEET.FITTOPAGE&quot; /&gt;
&lt;/pageSetupPr&gt;
&lt;/tt:cond&gt;
&lt;dimension&gt;
&lt;tt:attribute name=&quot;ref&quot; value-ref=&quot;WORKSHEET.DIMENSION&quot; /&gt;
&lt;/dimension&gt;
&lt;sheetViews&gt;
&lt;sheetView&gt;
&lt;tt:attribute name=&quot;showZeros&quot; value-ref=&quot;WORKSHEET.SHOWZEROS&quot; /&gt;
&lt;tt:attribute name=&quot;tabSelected&quot; value-ref=&quot;WORKSHEET.TABSELECTED&quot; /&gt;
&lt;tt:attribute name=&quot;zoomScale&quot; value-ref=&quot;WORKSHEET.ZOOMSCALE&quot; /&gt;
&lt;tt:cond check=&quot;WORKSHEET.ZOOMSCALENORMAL != 0&quot;&gt;
&lt;tt:attribute name=&quot;zoomScaleNormal&quot; value-ref=&quot;WORKSHEET.ZOOMSCALENORMAL&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;WORKSHEET.ZOOMSCALEPAGEVIEW != 0&quot;&gt;
&lt;tt:attribute name=&quot;zoomScalePageLayoutView&quot; value-ref=&quot;WORKSHEET.ZOOMSCALEPAGEVIEW&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:attribute name=&quot;zoomScaleSheetLayoutView&quot; value-ref=&quot;WORKSHEET.ZOOMSCALESHEETVIEW&quot; /&gt;
&lt;tt:attribute name=&quot;workbookViewId&quot; value-ref=&quot;WORKSHEET.WORKBOOKVIEWID&quot; /&gt;
&lt;tt:attribute name=&quot;showGridLines&quot; value-ref=&quot;WORKSHEET.SHOWGRIDLINES&quot; /&gt;
&lt;tt:attribute name=&quot;showRowColHeaders&quot; value-ref=&quot;WORKSHEET.SHOWROWCOLHEADERS&quot; /&gt;
&lt;tt:cond check=&quot;WORKSHEET.YSPLIT != 0 or WORKSHEET.XSPLIT != 0&quot;&gt;
&lt;pane activePane=&quot;bottomRight&quot; state=&quot;frozen&quot;&gt;
&lt;tt:cond check=&quot;WORKSHEET.YSPLIT != 0&quot;&gt;
&lt;tt:attribute name=&quot;ySplit&quot; value-ref=&quot;WORKSHEET.YSPLIT&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;WORKSHEET.XSPLIT != 0&quot;&gt;
&lt;tt:attribute name=&quot;xSplit&quot; value-ref=&quot;WORKSHEET.XSPLIT&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:attribute name=&quot;topLeftCell&quot; value-ref=&quot;WORKSHEET.TOPLEFTCELL&quot; /&gt;
&lt;/pane&gt;
&lt;/tt:cond&gt;
&lt;selection&gt;
&lt;tt:attribute name=&quot;activeCell&quot; value-ref=&quot;WORKSHEET.ACTIVECELL&quot; /&gt;
&lt;tt:attribute name=&quot;sqref&quot; value-ref=&quot;WORKSHEET.ACTIVECELL&quot; /&gt;
&lt;/selection&gt;
&lt;/sheetView&gt;
&lt;/sheetViews&gt;
&lt;sheetFormatPr&gt;
&lt;tt:attribute name=&quot;defaultRowHeight&quot; value-ref=&quot;WORKSHEET.DEFAULTROWHEIGHT&quot; /&gt;
&lt;tt:cond check=&quot;WORKSHEET.DEFAULTCOLWIDTH != 0&quot;&gt;
&lt;tt:attribute name=&quot;defaultColWidth&quot; value-ref=&quot;WORKSHEET.DEFAULTCOLWIDTH&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:attribute name=&quot;x14ac:outlineLevelRow&quot; value-ref=&quot;WORKSHEET.OUTLINELEVELROW&quot; /&gt;
&lt;tt:attribute name=&quot;x14ac:outlineLevelCol&quot; value-ref=&quot;WORKSHEET.OUTLINELEVELCOL&quot; /&gt;
&lt;/sheetFormatPr&gt;
&lt;cols&gt;
&lt;tt:loop ref=&quot;WORKSHEET.COLS&quot;&gt;
&lt;col&gt;
&lt;tt:attribute name=&quot;min&quot; value-ref=&quot;MIN&quot; /&gt;
&lt;tt:attribute name=&quot;max&quot; value-ref=&quot;MAX&quot; /&gt;
&lt;tt:attribute name=&quot;width&quot; value-ref=&quot;WIDTH&quot; /&gt;
&lt;tt:cond check=&quot;not-initial(HIDDEN)&quot;&gt;
&lt;tt:attribute name=&quot;hidden&quot; value-ref=&quot;HIDDEN&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(CUSTOMWIDTH)&quot;&gt;
&lt;tt:attribute name=&quot;customWidth&quot; value-ref=&quot;CUSTOMWIDTH&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(BESTFIT)&quot;&gt;
&lt;tt:attribute name=&quot;bestFit&quot; value-ref=&quot;BESTFIT&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(COLLAPSED)&quot;&gt;
&lt;tt:attribute name=&quot;collapsed&quot; value-ref=&quot;COLLAPSED&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;OUTLINELEVEL != 0&quot;&gt;
&lt;tt:attribute name=&quot;outlineLevel&quot; value-ref=&quot;OUTLINELEVEL&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;STYLE &gt;= 0&quot;&gt;
&lt;tt:attribute name=&quot;style&quot; value-ref=&quot;STYLE&quot; /&gt;
&lt;/tt:cond&gt;
&lt;/col&gt;
&lt;/tt:loop&gt;
&lt;/cols&gt;
&lt;sheetData&gt;
&lt;tt:loop ref=&quot;WORKSHEET.ROWS&quot;&gt;
&lt;row&gt;
&lt;tt:attribute name=&quot;r&quot; value-ref=&quot;ROW&quot; /&gt;
&lt;tt:attribute name=&quot;spans&quot; value-ref=&quot;SPANS&quot; /&gt;
&lt;tt:cond check=&quot;not-initial(HIDDEN)&quot;&gt;
&lt;tt:attribute name=&quot;hidden&quot; value-ref=&quot;HIDDEN&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(CUSTOMHEIGHT)&quot;&gt;
&lt;tt:attribute name=&quot;customHeight&quot; value-ref=&quot;CUSTOMHIGHT&quot; /&gt;
&lt;tt:attribute name=&quot;ht&quot; value-ref=&quot;HIGHT&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(COLLAPSED)&quot;&gt;
&lt;tt:attribute name=&quot;collapsed&quot; value-ref=&quot;COLLAPSED&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;OUTLINELEVEL != 0&quot;&gt;
&lt;tt:attribute name=&quot;outlineLevel&quot; value-ref=&quot;OUTLINELEVEL&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;STYLE != 0&quot;&gt;
&lt;tt:attribute name=&quot;customFormat&quot; value-ref=&quot;CUSTOMFORMAT&quot; /&gt;
&lt;tt:attribute name=&quot;s&quot; value-ref=&quot;STYLE&quot; /&gt;
&lt;/tt:cond&gt;
&lt;!-- Aufruf get_cells --&gt;
&lt;tt:call-method s-name=&quot;GET_CELLS&quot; var=&quot;owriter&quot;&gt;
&lt;tt:with-parameter name=&quot;I_ROW&quot; ref=&quot;ROW&quot; /&gt;
&lt;tt:with-parameter name=&quot;I_INDEX&quot; ref=&quot;INDEX&quot; /&gt;
&lt;/tt:call-method&gt;
&lt;tt:loop ref=&quot;.CELLS&quot;&gt;
&lt;c&gt;
&lt;tt:attribute name=&quot;r&quot; value-ref=&quot;NAME&quot; /&gt;
&lt;tt:cond check=&quot;STYLE &gt;= 0&quot;&gt;
&lt;tt:attribute name=&quot;s&quot; value-ref=&quot;STYLE&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(FORMULA)&quot;&gt;
&lt;tt:attribute name=&quot;f&quot; value-ref=&quot;FORMULA&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(VALUE) and initial(FORMULA)&quot;&gt;
&lt;tt:attribute name=&quot;t&quot; value-ref=&quot;TYPE&quot; /&gt;
&lt;tt:cond check=&quot;TYPE = &apos;inlineStr&apos;&quot;&gt;
&lt;is&gt;
&lt;t&gt;
&lt;tt:value ref=&quot;VALUE&quot; /&gt;
&lt;/t&gt;
&lt;/is&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;TYPE != &apos;inlineStr&apos;&quot;&gt;
&lt;v&gt;
&lt;tt:value ref=&quot;VALUE&quot; /&gt;
&lt;/v&gt;
&lt;/tt:cond&gt;
&lt;/tt:cond&gt;
&lt;/c&gt;
&lt;/tt:loop&gt;
&lt;/row&gt;
&lt;/tt:loop&gt;
&lt;/sheetData&gt;
&lt;tt:cond check=&quot;WORKSHEET.MERGECELLS_COUNT != 0&quot;&gt;
&lt;mergeCells&gt;
&lt;tt:attribute name=&quot;count&quot; value-ref=&quot;WORKSHEET.MERGECELLS_COUNT&quot; /&gt;
&lt;tt:loop ref=&quot;WORKSHEET.MERGECELLS&quot;&gt;
&lt;mergeCell&gt;
&lt;tt:attribute name=&quot;ref&quot; value-ref=&quot;REF&quot; /&gt;
&lt;/mergeCell&gt;
&lt;/tt:loop&gt;
&lt;/mergeCells&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;WORKSHEET.HYPERLINKS_COUNT != 0&quot;&gt;
&lt;hyperlinks&gt;
&lt;tt:loop ref=&quot;WORKSHEET.HYPERLINKS&quot;&gt;
&lt;hyperlink&gt;
&lt;tt:attribute name=&quot;ref&quot; value-ref=&quot;REF&quot; /&gt;
&lt;tt:cond check=&quot;not-initial(LOCATION)&quot;&gt;
&lt;tt:attribute name=&quot;location&quot; value-ref=&quot;LOCATION&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(R_ID)&quot;&gt;
&lt;tt:attribute name=&quot;r:id&quot; value-ref=&quot;R_ID&quot; /&gt;
&lt;/tt:cond&gt;
&lt;/hyperlink&gt;
&lt;/tt:loop&gt;
&lt;/hyperlinks&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(WORKSHEET.PRINTOPTIONS)&quot;&gt;
&lt;printOptions&gt;
&lt;tt:ref name=&quot;WORKSHEET.PRINTOPTIONS&quot;&gt;
&lt;tt:cond check=&quot;not-initial(GRIDLINES)&quot;&gt;
&lt;tt:attribute name=&quot;gridLines&quot; value-ref=&quot;GRIDLINES&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(HORIZONTALCENTERED)&quot;&gt;
&lt;tt:attribute name=&quot;horizontalCentered&quot; value-ref=&quot;HORIZONTALCENTERED&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(VERTICALCENTERED)&quot;&gt;
&lt;tt:attribute name=&quot;verticalCentered&quot; value-ref=&quot;VERTICALCENTERED&quot; /&gt;
&lt;/tt:cond&gt;
&lt;/tt:ref&gt;
&lt;/printOptions&gt;
&lt;/tt:cond&gt;
&lt;pageMargins&gt;
&lt;tt:ref name=&quot;WORKSHEET.PAGEMARGINS&quot;&gt;
&lt;tt:attribute name=&quot;left&quot; value-ref=&quot;LEFT&quot; /&gt;
&lt;tt:attribute name=&quot;right&quot; value-ref=&quot;RIGHT&quot; /&gt;
&lt;tt:attribute name=&quot;top&quot; value-ref=&quot;TOP&quot; /&gt;
&lt;tt:attribute name=&quot;bottom&quot; value-ref=&quot;BOTTOM&quot; /&gt;
&lt;tt:attribute name=&quot;header&quot; value-ref=&quot;HEADER&quot; /&gt;
&lt;tt:attribute name=&quot;footer&quot; value-ref=&quot;FOOTER&quot; /&gt;
&lt;/tt:ref&gt;
&lt;/pageMargins&gt;
&lt;pageSetup&gt;
&lt;tt:ref name=&quot;WORKSHEET.PAGESETUP&quot;&gt;
&lt;tt:cond check=&quot;not-initial(BLACKANDWHITE)&quot;&gt;
&lt;tt:attribute name=&quot;blackAndWhite&quot; value-ref=&quot;BLACKANDWHITE&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(CELLCOMMENTS)&quot;&gt;
&lt;tt:attribute name=&quot;cellComments&quot; value-ref=&quot;CELLCOMMENTS&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;COPIES != 0&quot;&gt;
&lt;tt:attribute name=&quot;copies&quot; value-ref=&quot;COPIES&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(DRAFT)&quot;&gt;
&lt;tt:attribute name=&quot;draft&quot; value-ref=&quot;DRAFT&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(ERRORS)&quot;&gt;
&lt;tt:attribute name=&quot;errors&quot; value-ref=&quot;ERRORS&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;FIRSTPAGENUMBER != 0&quot;&gt;
&lt;tt:attribute name=&quot;firstPageNumber&quot; value-ref=&quot;FIRSTPAGENUMBER&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(FITTOPAGE)&quot;&gt;
&lt;tt:attribute name=&quot;fitToHeight&quot; value-ref=&quot;FITTOHIGHT&quot; /&gt;
&lt;tt:attribute name=&quot;fitToWidth&quot; value-ref=&quot;FITTOWIDTH&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;HORIZONTALDPI != 0&quot;&gt;
&lt;tt:attribute name=&quot;horizontalDpi&quot; value-ref=&quot;HORIZONTALDPI&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(ORIENTATION)&quot;&gt;
&lt;tt:attribute name=&quot;orientation&quot; value-ref=&quot;ORIENTATION&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(PAGEORDER)&quot;&gt;
&lt;tt:attribute name=&quot;pageOrder&quot; value-ref=&quot;PAGEORDER&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(PAPERHEIGHT)&quot;&gt;
&lt;tt:attribute name=&quot;paperHeight&quot; value-ref=&quot;PAPERHEIGHT&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;PAPERSIZE != 0&quot;&gt;
&lt;tt:attribute name=&quot;paperSize&quot; value-ref=&quot;PAPERSIZE&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(PAPERWIDTH)&quot;&gt;
&lt;tt:attribute name=&quot;paperWidth&quot; value-ref=&quot;PAPERWIDTH&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;SCALE != 0&quot;&gt;
&lt;tt:attribute name=&quot;scale&quot; value-ref=&quot;SCALE&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(USEFIRSTPAGENUMBER)&quot;&gt;
&lt;tt:attribute name=&quot;useFirstPageNumber&quot; value-ref=&quot;USEFIRSTPAGENUMBER&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(USEPRINTERDEFAULTS)&quot;&gt;
&lt;tt:attribute name=&quot;usePrinterDefaults&quot; value-ref=&quot;USEPRINTERDEFAULTS&quot; /&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;VERTICALDPI != 0&quot;&gt;
&lt;tt:attribute name=&quot;verticalDpi&quot; value-ref=&quot;VERTICALDPI&quot; /&gt;
&lt;/tt:cond&gt;
&lt;/tt:ref&gt;
&lt;/pageSetup&gt;
&lt;tt:cond check=&quot;not-initial(WORKSHEET.HEADERFOOTER)&quot;&gt;
&lt;headerFooter&gt;
&lt;tt:ref name=&quot;WORKSHEET.HEADERFOOTER&quot;&gt;
&lt;tt:cond check=&quot;not-initial(WORKSHEET.HEADERFOOTER)&quot;&gt;
&lt;tt:attribute name=&quot;differentOddEven&quot; value-ref=&quot;DIFFERENTODDEVEN&quot; /&gt;
&lt;/tt:cond&gt;
&lt;oddHeader&gt;
&lt;tt:value ref=&quot;ODDHEADER&quot; /&gt;
&lt;/oddHeader&gt;
&lt;oddFooter&gt;
&lt;tt:value ref=&quot;ODDFOOTER&quot; /&gt;
&lt;/oddFooter&gt;
&lt;evenHeader&gt;
&lt;tt:value ref=&quot;EVENHEADER&quot; /&gt;
&lt;/evenHeader&gt;
&lt;evenFooter&gt;
&lt;tt:value ref=&quot;EVENFOOTER&quot; /&gt;
&lt;/evenFooter&gt;
&lt;/tt:ref&gt;
&lt;/headerFooter&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;not-initial(WORKSHEET.DRAWINGS)&quot;&gt;
&lt;drawing&gt;
&lt;tt:attribute name=&quot;r:id&quot; value-ref=&quot;WORKSHEET.DRAWINGS&quot; /&gt;
&lt;/drawing&gt;
&lt;/tt:cond&gt;
&lt;tt:cond check=&quot;WORKSHEET.TABLES_COUNT != 0&quot;&gt;
&lt;mergeCells&gt;
&lt;tt:attribute name=&quot;count&quot; value-ref=&quot;WORKSHEET.TABLES_COUNT&quot; /&gt;
&lt;tt:loop ref=&quot;WORKSHEET.TABLES&quot;&gt;
&lt;tablePart&gt;
&lt;tt:attribute name=&quot;r:id&quot; value-ref=&quot;R_ID&quot; /&gt;
&lt;/tablePart&gt;
&lt;/tt:loop&gt;
&lt;/mergeCells&gt;
&lt;/tt:cond&gt;
&lt;/worksheet&gt;
&lt;/tt:template&gt;
&lt;/tt:transform&gt;</source>
</XSLT>