M
MarcG
I am using an xslt to transform a dataset into a formatted spreadsheet.
I got the base xml by opening Excel, formatting the rows and columns the way
I wanted them; setting up a header row; specifying the print area; and
setting one of the columns to text/wrap. I then entered one data row and
saved the whole thing as an XML spreadsheet (Excel xml, i.e., XMLSS).
I then set up the xslt. For the root, I included all of the xmlss that
preceeded the data row, then put in an apply-template that repeated for each
data row in the dataset, and followed this with all of the trailing xmlss.
In the template that handles the data row, I took the xmlss for the
<row>...</row> node and inserted the record field values into the <data>
nodes.
The template basically looks like:
<Row>
<Cell ss:StyleID="s92">
<Data ss:Type="String">
<xsl:value-of select="BayNo"/>
</Data>
</Cell>
....
....
<Cell ss:StyleID="s97">
<Data ss:Type="String">
<xsl:value-of select="NoteText"/>
</Data>
</Cell>
</Row>
The whole process actually works like a dream ... my web app sends the xml
to the browser with approptiate headers and up pops Excel with the
spreadsheet in it.
Except for one problem. The last column in each row contains wrapped text
however, the row itself does not autosize. The effect looks as though the
data in the cell is truncated. But if you manually autosize the row, it
adjusts to the proper height and shows all of the text.
Note that the last cell above uses ss:StyleID="s97" which is defined as
follows:
<Style ss:ID="s97">
<Alignment ss:Vertical="Top" ss:WrapText="1"/>
<Borders>
<Border ssosition="Bottom" ss:LineStyle="Continuous"
ss:Weight="1"/>
<Border ssosition="Left" ss:LineStyle="Continuous"
ss:Weight="1"/>
<Border ssosition="Right" ss:LineStyle="Continuous"
ss:Weight="2"/>
<Border ssosition="Top" ss:LineStyle="Continuous"
ss:Weight="2"/>
</Borders>
<Font ss:Size="11"/>
</Style>
Note ss:WrapText="1"
Now, if you open a new spreadsheet, set a column to text/wrap and start
typing, it will automatically wrap and the row will assume the proper height
when you exit the cell. Save this as an xml spreadsheet. then select the
entire sheet and Format|Row|Autofit and save it again under a different file
name.
Compare the two xml files and they are identical - the Format|Row|Autofit
leaves no markup in the output. Not only that, but the row you entered the
wrapped text in has an explicit height setting, e.g., <Row ss:Height="210.25">
So, my question is: What can I put in the xml that will force Excel to
autosize the row based on the content in wrapped text cells?
Thx
Marc
I got the base xml by opening Excel, formatting the rows and columns the way
I wanted them; setting up a header row; specifying the print area; and
setting one of the columns to text/wrap. I then entered one data row and
saved the whole thing as an XML spreadsheet (Excel xml, i.e., XMLSS).
I then set up the xslt. For the root, I included all of the xmlss that
preceeded the data row, then put in an apply-template that repeated for each
data row in the dataset, and followed this with all of the trailing xmlss.
In the template that handles the data row, I took the xmlss for the
<row>...</row> node and inserted the record field values into the <data>
nodes.
The template basically looks like:
<Row>
<Cell ss:StyleID="s92">
<Data ss:Type="String">
<xsl:value-of select="BayNo"/>
</Data>
</Cell>
....
....
<Cell ss:StyleID="s97">
<Data ss:Type="String">
<xsl:value-of select="NoteText"/>
</Data>
</Cell>
</Row>
The whole process actually works like a dream ... my web app sends the xml
to the browser with approptiate headers and up pops Excel with the
spreadsheet in it.
Except for one problem. The last column in each row contains wrapped text
however, the row itself does not autosize. The effect looks as though the
data in the cell is truncated. But if you manually autosize the row, it
adjusts to the proper height and shows all of the text.
Note that the last cell above uses ss:StyleID="s97" which is defined as
follows:
<Style ss:ID="s97">
<Alignment ss:Vertical="Top" ss:WrapText="1"/>
<Borders>
<Border ssosition="Bottom" ss:LineStyle="Continuous"
ss:Weight="1"/>
<Border ssosition="Left" ss:LineStyle="Continuous"
ss:Weight="1"/>
<Border ssosition="Right" ss:LineStyle="Continuous"
ss:Weight="2"/>
<Border ssosition="Top" ss:LineStyle="Continuous"
ss:Weight="2"/>
</Borders>
<Font ss:Size="11"/>
</Style>
Note ss:WrapText="1"
Now, if you open a new spreadsheet, set a column to text/wrap and start
typing, it will automatically wrap and the row will assume the proper height
when you exit the cell. Save this as an xml spreadsheet. then select the
entire sheet and Format|Row|Autofit and save it again under a different file
name.
Compare the two xml files and they are identical - the Format|Row|Autofit
leaves no markup in the output. Not only that, but the row you entered the
wrapped text in has an explicit height setting, e.g., <Row ss:Height="210.25">
So, my question is: What can I put in the xml that will force Excel to
autosize the row based on the content in wrapped text cells?
Thx
Marc