0

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

F0r3v3r-A-N00b
  • 2,903
  • 4
  • 26
  • 36
  • I'd think you'd apply the formatting in Excel. [Strings.Format](https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.strings.format) returns a String which is what Excel is complaining about. – Étienne Laneville Jun 02 '23 at 00:30

1 Answers1

0

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
                 )
F0r3v3r-A-N00b
  • 2,903
  • 4
  • 26
  • 36