I'm looking for a way to format a number:
<ss:Cell>
<ss:Data ss:Type="Number">@importExportOption.StrikePrice</ss:Data>
</ss:Cell>
To a fixed number of decimal places. Where do I start?
I'm looking for a way to format a number:
<ss:Cell>
<ss:Data ss:Type="Number">@importExportOption.StrikePrice</ss:Data>
</ss:Cell>
To a fixed number of decimal places. Where do I start?
Your question is actually independent of Excel. You just need to look at the different .ToString()
overloads for numbers.
Specifically, you'd probably want something like: (taken from Kyle Rozendo's answer in the question here)
@string.Format("{0:N2}%", importExportOption.StrikePrice)
I didn't understand ss:Cell, but you can use this for number format (with rounding):
<ss:Cell>
<ss:Data ss:Type="Number">@Math.Round(importExportOption.StrikePrice, 2)</ss:Data>
</ss:Cell>