DEV Community

loading...

Format Excel Cell Numbers to Currency in C#.NET

asposecells profile image AsposeCells Updated on ・3 min read

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.

Article Description

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.

Supported Platforms

Aspose.Cells API supports all .NET frameworks e.g. .NET 2.0, .NET 3.5, .NET 4.0, .NET 7.0, .NET Core, .NET Standard 2.0, Xamarin etc. It is also available in other platforms e.g. Java, C++, Android, JavaScript, PHP etc. Besides, Aspose.Cells is available in Cloud as REST or RESTful APIs.

Licensing

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.

Format Excel Cell Numbers to Currency using Microsoft Excel

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.

Format Excel Cell Numbers to Currency using Microsoft Excel.

Currency Custom Number Format Strings of Cell

You can use various types of currency custom number format strings to display currencies e.g. Dollar, Yuan, Pound, Euro etc. and many others.

Dollar

"$"#,##0.00
Enter fullscreen mode Exit fullscreen mode

Yaun

[$¥-804]#,##0.00
Enter fullscreen mode Exit fullscreen mode

Pound

[$£-809]#,##0.00
Enter fullscreen mode Exit fullscreen mode

Euro

#,##0.00[$€-40B]
Enter fullscreen mode Exit fullscreen mode

Format Excel Cell Numbers to Currency using Aspose.Cells

In the next few sections, we will learn how to use Aspose.Cells API to format Excel cell numbers to currency.

Sample Input Microsoft Excel Document

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.

Currency formats will be applied on Input Excel file Cells using Aspose.Cells API.

Sample Code

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.

Output Microsoft Excel XLSX by Aspose.Cells after applying Currency formats

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.

Currency formats applied on Excel cells using Aspose.Cells API.

Discussion (2)

pic
Editor guide
Collapse
radumg profile image
Radu Gidei

@ben can we please tag posts like these as ads ? Aspose continuously post “articles” explaining how to use their paid-for product and do not make that clear in the posts at all.
As the articles are always specific to their product, I don’t feel they add much value to the site or community and would be better surfaces on their documentation site or blog.

Collapse
lokser profile image
lokser

Please extend curency samles, or discribe how correctly create other.