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

Free Support Forum - aspose.com

Setting display format does not work

Hi All,

I’m trying to use Aspose.Cells .NET to create Excel file.

I want to place decimal value from my application in Excel cell and show it as percentage. But I have very weird thing.

Here is a part of my code.

cells[rowIndex, 1].PutValue(myObject.Value); //where Value is decimal and equal to 0.43
cells[rowIndex, 1].Style.Number = 10;

So I’m expecting to see 43% on Excel but I have 4343,00%. I checked code in debug and I’m sure I sent 0.43.

Thanks.

Hi,

Thank you for considering Aspose.

Well, I have tested the issue you mentioned and I got the desired result 43.00%, as per the provided Style.Number format. This issue may be caused due to the use of an older version of Aspose.Cells. Following is my test code:

Workbook wb = new Workbook();
wb.Open("C:\\output1.xls");
Worksheet sheet = wb.Worksheets[0];
decimal percent = 0.43;
sheet.Cells[0, 0].PutValue(percent);
sheet.Cells[0, 0].Style.Number = 10;
wb.Save("c:\\style_column.xls");

Please try the attached latest version. Please share your complete code and template file, if you still face any problem in the latest fix.

Thank you & Best Regards,

Thanks for your reply.

I tried last version from your attachment but still have the same issue.

I’m sorry but I cannot share my code because it is a part of big application. But I attached part of Excel file with weird numbers. Maybe you will be able to understand what is wrong here.

Regards,
Sergey Roznikov.

Hi Sergey Roznikov,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, as per your excel file, the format of the cell which is showing 4343.00% is set as Custom = “43.00%”. It seems like cell B6’s format is not setting properly in the code. Please check the code where you are setting the display formats. If setting the format is not causing this problem then you may create some sample code or application and upload it as per your code. So we can explore the issue further.

Thank you & Best Regards,