AutoFitHeight and Height not working together

M

muddjones

In Microsoft's Spreadsheet XML documentation
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xmlss.asp),
I see the following under the <ss:Row> tag:
If ss:AutoFitHeight="1" and ss:Height is specified: Set the row
to the specified height and only autofit if the size of the content is
larger than the specified height

However, when I generate XML using both of these attributes
(ss:AutoFitHeight and ss:Height) on <Row>, and then try to open the XML
file in Excel, it is not doing the AutoFitHeight. I need to use both
attributes, because my users want the row height to be 18.75 (this
number is in points) unless text in the row needs to be wrapped, then
they want the row to auto fit.

I have tried using the above attributes in various combinations with
DefaultRowHeight in the <Table> tag, nothing worked. I also tried
going into Excel performing the actions and then saving the file as XML
to see how Excel is writing out the information in XML. They are not
writing out the AutoFitHeight tag, they are adjusting the value of
ss:Height and writing that out. I was trying to avoid having to come
up with some formula myself for knowing when to adjust my ss:Height
manually as Excel seems to be doing. That would be quite difficult
since my users want to use Times New Roman font - where all letters do
not have the same width.

Has anyone else experienced this or have any ideas? Any help would be
greatly appreciated. Thanks!

Here is a sample test XML file that I am using:
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:eek:ffice:spreadsheet"
xmlns:eek:="urn:schemas-microsoft-com:eek:ffice:eek:ffice"
xmlns:x="urn:schemas-microsoft-com:eek:ffice:excel"
xmlns:ss="urn:schemas-microsoft-com:eek:ffice:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:eek:ffice:eek:ffice">
<Author>me</Author>
<LastAuthor>me</LastAuthor>
<Created>2005-09-30T19:30:49Z</Created>
<Company>mycompany</Company>
<Version>10.4219</Version>
</DocumentProperties>
<OfficeDocumentSettings
xmlns="urn:schemas-microsoft-com:eek:ffice:eek:ffice">
<DownloadComponents/>
<LocationOfComponents HRef="file:///D:\"/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:eek:ffice:excel">
<WindowHeight>8955</WindowHeight>
<WindowWidth>14235</WindowWidth>
<WindowTopX>480</WindowTopX>
<WindowTopY>90</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s21">
<Font ss:FontName="Times New Roman" x:Family="Roman" ss:Size="12"/>
</Style>
<Style ss:ID="s22">
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
<Font ss:FontName="Times New Roman" x:Family="Roman" ss:Size="12"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="7"
x:FullColumns="1"
x:FullRows="1" ss:StyleID="s21">
<Column ss:StyleID="s22" ss:AutoFitWidth="0" ss:Width="95.25"/>
<Row ss:AutoFitHeight="1" ss:Height="18.75">
<Cell><Data ss:Type="String">Long name before autofit - row
1</Data></Cell>
</Row>
<Row ss:AutoFitHeight="1" ss:Height="18.75">
<Cell><Data ss:Type="String">row 2</Data></Cell>
</Row>
<Row ss:AutoFitHeight="1" ss:Height="18.75">
<Cell><Data ss:Type="String">Long name after autofit - row
3</Data></Cell>
</Row>
<Row ss:AutoFitHeight="1" ss:Height="18.75"/>
<Row ss:AutoFitHeight="1" ss:Height="18.75">
<Cell><Data ss:Type="String">Long name after autofit but no enter
when done - row 5</Data></Cell>
</Row>
<Row ss:AutoFitHeight="1" ss:Height="18.75"/>
<Row ss:AutoFitHeight="1" ss:Height="18.75">
<Cell><Data ss:Type="String">Long name before autofit but autofit
when done - row 7</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:eek:ffice:excel">
<Unsynced/>
<Print>
<ValidPrinterInfo/>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet2">
<WorksheetOptions xmlns="urn:schemas-microsoft-com:eek:ffice:excel">
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet3">
<WorksheetOptions xmlns="urn:schemas-microsoft-com:eek:ffice:excel">
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top