Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

AsposeCells
AsposeCells

Posted on • Edited on

     

Format Excel Cell Numbers to Currency in C#.NET

Microsoft Excel supports wide range ofNumber Formats. One of these number formats isCurrency. 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 usingAspose.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 a30 Day Temporary License. For more information, please go throughLicensing.

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.
  • ClickFormat Cells… from the context menu as shown in snapshot below.
  • SelectCurrency fromNumber Category and pressOK.

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 modeExit fullscreen mode

Yaun

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

Pound

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

Euro

#,##0.00[$€-40B]
Enter fullscreen modeExit 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 followingsample 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 theinput Excel file inside theAspose.Cells.Workbook object and access the first worksheet.
  • Access first cell i.e. G3 and apply currency format using theStyle.Custom property.
  • Repeat the second step for cell G4, G5 and G6 with further currency formats.
  • Save theAspose.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 theOutput 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.

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
radumg profile image
Radu Gidei
  • Joined

@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.

CollapseExpand
 
lokser profile image
lokser
  • Joined

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

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Manipulate Excel Spreadsheets in Any Platform using Aspose.Cells API.Develop applications to Create, Edit, Convert or Render Excel spreadsheets, using our APIs for .NET, Java, C++ and Android.
  • Joined

More fromAsposeCells

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp