Set numeric cell value to be formatted as #,##0.00

103 Views Asked by At

In SpreadsheetLight, how can I set the numeric value into a #,##0.00 format? Tried using Format(value, "#,##0.00") but the output Excel file shows warnings that 'Number in this cell is formatted as text or preceded by an apostrophe'. Tried the following codes:

These two produce the above warning:

sld.SetCellValue(rowIndex, columnIndex, Format(row(column.ColumnName), "###0.00"))
sld.SetCellValue(rowIndex, columnIndex, Format(row(column.ColumnName), "#,##0.00"))

This doesn't have a warning but the output is not formatted:

sld.SetCellValue(rowIndex, columnIndex, row(column.ColumnName))

I want the output to be formatted but not stored as text in Excel.

TIA

1

There are 1 best solutions below

0
F0r3v3r-A-N00b On

Found the answer:

You have to declare a style then apply that style to your desired range

Dim style As SLStyle = sld.CreateStyle
style.FormatCode = "#,##0.00;(#,##0.00)"
sld.SetCellStyle(1,
                 1,
                 totalRows,
                 totalColumns,
                 style
                 )