EasyXLS

Number and date format

EasyXLS™ library enables you to apply number formats, date and time formats, accounting formats, text formats or custom formats for values inside the spreadsheet cells. The format can be set per cell, per row and per column.

For better performances, the best option is to apply the format to the style of the cell, row or column by using ExcelStyle class. But the formatting can also be applied directly to the cell, row or column.

Apply format to cell, row or column

The below source code sample shows how to set the “$0.00” currency format for a cell style from the spreadsheet.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

General format

By default, General format is used for all cells from spreadsheet. If you need to revert the cell format to default format, use the source code below:

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Number format

The number format includes 1000 separator, decimal separator, decimal places and the aspect for negative numbers. The 1000 separator must be always set as "," and decimal separator as ".". The regional settings from the machine are used when the Excel file is opened, and the separators set in Control Panel define the displayed separators on screen.

The below source code sample shows how to set number format for integer numbers, decimal numbers and negative numbers.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Currency format

The currency format includes 1000 separator, decimal separator, decimal places, currency symbol and the aspect for negative numbers. The 1000 separator must be always set as "," and decimal separator as ".". The regional settings from the machine are used when the Excel file is opened, and the separators set in Control Panel define the displayed separators on screen.

The below source code sample shows how to set the default currency format and a currency format for negative numbers.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Accounting format

The accounting format includes 1000 separator, decimal separator, decimal places, currency symbol and the aspect for negative numbers. The 1000 separator must be always set as "," and decimal separator as ".". The regional settings from the machine are used when the Excel file is opened, and the separators set in Control Panel define the displayed separators on screen.

The below source code sample shows how to set the default accounting format.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Date format

The date format is used to set how a date is displayed on screen. Some date formats depend by the regional settings from the machine, others do not.

For better performances, a date value must be entered as "MM/dd/yyyy HH:mm:ss" and the desired date format applied later to the cell.

The below source code sample shows how to set the default date format and date with regional settings.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Time format

The time format is used to set how time fraction is displayed on screen. Part of time formats depend by the regional settings from the machine, others do not.

For better performances, a date value must be entered as "MM/dd/yyyy HH:mm:ss" and the time format applied later to the cell.

The below source code sample shows how to set the custom time format and date time with regional settings.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Percent format

The percent format is used to display numbers as percentages.

The below source code sample shows how to set the percentage format.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Available for: Professional, Excel Writer, Excel Reader
Go to top

EasyXLS Excel libraries:

.NET
.NET Excel Library
full .NET version to import, export or convert Excel files
COM+ Excel Library
full COM+ version to import, export or convert Excel files
-
Java
Java Excel Library
full Java version to import, export or convert Excel files
Download EasyXLS™ Excel Library for .NET and Java

File formats:

Office 365
MS Excel 2021 - 2024
MS Excel 2007 - 2019
MS Excel 97 - 2003
XLSXXLSMXLSBXLS
XMLHTMLCSVTXT