We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Number format

var numberStyle = wb.CreateStyle();

numberStyle.Number = 48;

var numberStyleFlag = new StyleFlag { NumberFormat = true };





Cell is not formatting to number.



foreach (Cell c in vqSheet.Cells.Rows[0])

{

if (c.Value.ToString().ToUpper().Contains(“UTC”) || c.Value.ToString().Trim().ToUpper().Equals(“TIME”))

{

vqSheet.Cells.Columns[c.Column].ApplyStyle(dateStyle, dateStyleFlag);

}

else if (c.Value.ToString().ToUpper().Contains(“PROBE SERIAL NUMBER”))

{

vqSheet.Cells.Columns[c.Column].ApplyStyle(textStyle, textStyleFlag);

}

else if (c.Value.ToString().ToUpper().Contains(“DEVICE MODEL”))

{

vqSheet.Cells.Columns[c.Column].ApplyStyle(textStyle, textStyleFlag);

}

else if (c.Value.ToString().ToUpper().Contains(“DEVICE MAKE”))

{

vqSheet.Cells.Columns[c.Column].ApplyStyle(textStyle, textStyleFlag);

}

else

{

vqSheet.Cells.Columns[c.Column].ApplyStyle(numberStyle, numberStyleFlag);

}

}

Hi,

Thanks for your posting and using Aspose.Cells.

I have tested your code with the following sample code and found that it is working fine with the latest version:

        <a href="https://forum.aspose.com/t/136572">Aspose.Cells
            for .NET v8.6.3.3</a>. Please check the source excel file used in the code and the output excel file generated by it. I have attached both of them for your reference. After the execution of the code, the column A in source excel file is formatted with your number format.<br><br><b>C#</b><br><div class="csharpcode"><font color="#800080">Workbook wb = new Workbook("source.xlsx");<br><br>Worksheet worksheet = wb.Worksheets[0];<br><br>Column col = worksheet.Cells.Columns[0];<br><br>var numberStyle = wb.CreateStyle();<br>numberStyle.Number = 48;<br>var numberStyleFlag = new StyleFlag { NumberFormat = true };<br><br>col.ApplyStyle(numberStyle, numberStyleFlag);<br><br>wb.Save("output.xlsx");<br><br></font></div><br>