Syncfusion.XlsIO.Base
Example 


NumberFormatIndex Property

Gets / Sets format index.
Syntax
'Declaration
 
Property NumberFormatIndex As Integer
'Usage
 
Dim instance As IExtendedFormat
Dim value As Integer
 
instance.NumberFormatIndex = value
 
value = instance.NumberFormatIndex
int NumberFormatIndex {get; set;}
Remarks
To know more about number formats refer Apply Number Formats.
Example
By default, XlsIO holds 36 number format types that can be applied by just setting NumberFormatIndex. Here for example, we set number format in the 5th index to apply. To get more customization we can use NumberFormat to set number formatting string.
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 = "1234.40";
            
            //Add style
            IStyle style = workbook.Styles.Add("CustomStyle");
            
            //Set style
            worksheet["C2"].CellStyle = style;
            
            //Set number format index
            style.NumberFormatIndex = 5;
            
            //Get extended format
            IExtendedFormat format = worksheet["E2"].CellStyle;
            
            //Set number format index
            format.NumberFormatIndex = 5;
            
            //Save and dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also