Syncfusion.XlsIO.Base
Example 


NumberFormat Property (IExtendedFormat)

Returns or sets the number format code for the IStyle object. Read / write String.
Syntax
'Declaration
 
Property NumberFormat As String
'Usage
 
Dim instance As IExtendedFormat
Dim value As String
 
instance.NumberFormat = value
 
value = instance.NumberFormat
string NumberFormat {get; set;}
Remarks
To know more about number formats refer Apply Number Formats.
Example
The following code illustrates how to set number format for the IStyle.
using Syncfusion.XlsIO;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Set text
            worksheet["C2"].Value = "1200.40";
            worksheet["E2"].Value = "1340.40";
            
            //Add style
            IStyle style = workbook.Styles.Add("CustomStyle");
            
            //Set style
            worksheet["C2"].CellStyle = style;
            
            //Set number format
            style.NumberFormat = "#,##0.00_);[Red](#,##0.00)";
            
            //Get extended format
            IExtendedFormat format = worksheet["E2"].CellStyle;
            
            //Set number format
            format.NumberFormat = "#,##0.00_);[Red](#,##0.00)";
            
            //Save and dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also