Free Support Forum -

Format cell to display percentage and currency symbol

I was wondering if there is a way to set style on a cell when using Aspose.Cells to display a percentage symbol and a currency symbol?



This message was posted using Aspose.Live 2 Forum

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

Thank you for considering Aspose.

You may use Style.Number & Style.Custom properties to set different display styles of cells. Please see the following sample code in this regard:

//Instantiating a Workbook object

Workbook workbook = new Workbook();

//Obtaining the reference of the newly added worksheet by passing its sheet index

Worksheet worksheet = workbook.Worksheets[0];

//Adding the value to "A1" cell


//Get Cell Style

Style style = worksheet.Cells["A1"].GetStyle();

//Setting the display format of the cell as currency

style.Number = 5;

//Set Style


//Adding the value to "A2" cell


style = worksheet.Cells["A2"].GetStyle();

//Setting the display format of the cell as percentage

style.Number = 9;


//Adding the value to "A3" cell


style = worksheet.Cells["A3"].GetStyle();

//Setting the display format of the cell with currency and percentage sign as Custom Style

style.Custom = "$#,##0%";


//Saving the Excel file


For Further details, you may check the following documentation link:

Thank You & Best Regards,