Reputation: 11
i use following xml file and open it in Excel
the view
@{
Layout = null;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=" + "1.xls");
}
<?xml version="1.0"?> <ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<ss:Styles>
<ss:Style ss:ID="DateLiteral">
<NumberFormat ss:Format="General Number"/>
</ss:Style>
</ss:Styles>
<ss:Worksheet ss:Name="Sheet1">
<ss:Table>
<ss:Row>
<ss:Cell ss:StyleID="DateLiteral">
<ss:Data ss:Type="Number">123.01</ss:Data>
</ss:Cell>
</ss:Row>
</ss:Table>
</ss:Worksheet> </ss:Workbook>
the format is still on General even i give format number. any help?
Upvotes: 1
Views: 542
Reputation: 107
look here for the custom codes to use:
http://office.microsoft.com/en-gb/excel-help/number-format-codes-HP005198679.aspx
But I would look at replacing this:
<ss:Style ss:ID="DateLiteral">
<NumberFormat ss:Format="General Number"/>
</ss:Style>
with the below if wanting a number
<ss:Style ss:ID="DateLiteral">
<NumberFormat ss:Format="0"/>
</ss:Style>
or below if wanting 12000 to display as 12,000.00 in custom rather than general
<ss:Style ss:ID="DateLiteral">
<NumberFormat ss:Format="#,##0.00"/>
</ss:Style>
I have spent all day hunting on the internet to find the above so I will answer this on any XML Spreadsheet query I find as it was annoying to find and difficult too.
Upvotes: 2