0

I want to put the number format for Peruvian Soles

Spreadsheetgear gave me this format: "S/."#,##0_);("S/."#,##0) - but I don't know how to cast that string to put in:

reportWorkbook.Worksheets[WSNombre].Cells[CPasoMOS].NumberFormat = "HERE";

I tried:

reportWorkbook.Worksheets[WSNombre].Cells[CPasoMOS].NumberFormat = "S/. ###,##0.00"; 
reportWorkbook.Worksheets[WSNombre].Cells[CPasoMOS].NumberFormat = "S/.#,##0_";
reportWorkbook.Worksheets[WSNombre].Cells[CPasoMOS].NumberFormat = "S/.#,##0";

BUT none of the above works for me.

AnonJr
  • 2,759
  • 1
  • 26
  • 39

1 Answers1

0

Excel needs the quotation marks in "S/. " to recognise this as text.

You need to escape the quotes in your string like this:

reportWorkbook.Worksheets[WSNombre].Cells[CPasoMOS].NumberFormat = "\"S/. \"#,##0";

See also this guide to Excel formatting.

Xcheque
  • 583
  • 1
  • 5
  • 14