Microsoft Excel supports wide range of Number Formats. One of these number formats is Currency. If the cell value contains number, then you can apply currency format by specifying currency symbol and decimal places. Similarly, you can format Excel cell numbers to currency using Aspose.Cells for .NET with ease. In order to perform its operation, Aspose.Cells does not need Microsoft Excel or on any sort of Microsoft Office Automation, VBA (Visual Basic for Applications), VSTO (Visual Studio Tools for Office) etc.
The purpose of this article is to explain how developers can format Excel cell numbers to currency in C#.NET. Alternatively, you can use any .NET Framework supported language e.g. VB.NET etc.
Aspose.Cells is paid or commercial api, so it is not free or open source. Without license, it will work in evaluation mode with some limitations. If you want to test Aspose.Cells without evaluation version limitations, you can also request a 30 Day Temporary License. For more information, please go through Licensing.
You can format Excel cell numbers to currency using Microsoft Excel by performing these steps.
- Right Click the cell that contains some numeric value.
- Click Format Cells… from the context menu as shown in snapshot below.
- Select Currency from Number Category and press OK.
You can use various types of currency custom number format strings to display currencies e.g. Dollar, Yuan, Pound, Euro etc. and many others.
In the next few sections, we will learn how to use Aspose.Cells API to format Excel cell numbers to currency.
For demonstration, we will use the following sample input Microsoft Excel document that contains some numbers in cells G3, G4, G5 and G6. We will apply currency format i.e. Dollar, Yuan, Pound, Euro on these cells respectively.
The following sample code formats Excel cells i.e. G3, G4, G5 and G6 with currency formats i.e. Dollar, Yuan, Pound, Euro respectively by performing these steps.
- Load the input Excel file inside the Aspose.Cells.Workbook object and access the first worksheet.
- Access first cell i.e. G3 and apply currency format using the Style.Custom property.
- Repeat the second step for cell G4, G5 and G6 with further currency formats.
- Save the Aspose.Cells.Workbook object in XLSX format. You can also save it to XLS or other Excel formats as per your needs.
The following snapshot shows the Output Microsoft Excel XLSX by Aspose.Cells after applying currency formats on the cells G3, G4, G5 and G6. Similarly, you can apply all sorts of currency formats on Excel cells using Aspose.Cells API.