Formation cells with percentage values

Hi again,

How can I format a range of values (numbers) in cells to display with four decimal digits? i.e 123456 -----> 123456.0000%

Thank you!

Marcos

Hi,

Thanks for your question and using Aspose.Cells for .NET.

First, you will create a style object then you will set Range style using Range.ApplyStyle() method.

Please see the complete code below for your help. I have attached the screenshot and output file generated by the code for your reference.

C#


Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];


//Put some value in cell A1

worksheet.Cells[“A1”].PutValue(235);


Range range = worksheet.Cells.CreateRange(“A1:A10”);


Style style = workbook.CreateStyle();

style.Custom = “0.0000%”;


StyleFlag flag = new StyleFlag();

flag.All = true;


range.ApplyStyle(style, flag);


workbook.Save(@“F:\Shak-Data-RW\Downloads\output.xlsx”);

Screenshot