Column Number format to 4 decimal places

I am attempting to set a column to display 4 decimal places and the following code from one of your responses in the forms is not working:


Workbook wb = new Workbook();

// Create a Worksheet to get the first Worksheet.

Worksheet sheet = wb.Worksheets[0];

// Create Cells to fetch the all the cells of first sheet.

Cells cells = sheet.Cells;

// Format every value in the first column to four decimal places.

cells.Columns[0].Style.Custom = “0.0000”;
// write a decimal value
cells[“A1”].PutValue(0.12);

// Save the excel file.
wb.Save(“Test.xlsx”);

What am I missing?
I have tried setting the number format on the styleflag and that still did not work.
I found the solution (from another post):
// Creat a Workbook.
Workbook wb = new Workbook();

// Create a Worksheet to get the first Worksheet.
Worksheet sheet = wb.Worksheets[0];

// Create Cells to fetch the all the cells of first sheet.
Cells cells = sheet.Cells;

Style style = workbook.CreateStyle();
StyleFlag flag = new StyleFlag {NumberFormat = true};
style.Custom = "0.0000";
//Apply style to complete column
worksheet.Cells.Columns[0].ApplyStyle(style, flag);

// Save the excel file.
cells["A1"].PutValue(0.12);
wb.Save("Test.xlsx");

Hi,

Thanks for your posting and using Aspose.Cells.

It is good to know that you were able to find the solution on the forum. Let us know if you encounter any other issue, we will be glad to look into it and help you further.