EasyXLS

Formatting cells, columns and rows

EasyXLS™ library enables you to format Excel cells, rows, columns and cell ranges. The supported formatted options are:

- Cell text format: number format, currency format, date format, accounting format, percentage format, fraction format, text format and other custom formats
- Cell alignment: horizontal and vertical alignment, text indentation, wrap text and shrink options, merge cells, text rotation and text direction
- Cell font settings: font name, font size, foreground, bold ant italic options, underline style, strikethrough, superscript and subscript effects
- Cell border: border line style and color
- Cell fill settings: background color, pattern style, pattern color, gradient fill
- Cell protection: locked cells and hidden formulas

The Excel file can be formatted inclusive using themes for Office 2007-2013 spreadsheets.

EasyXLS provides a specific class, ExcelStyle, which stores all formatting settings. The ExcelStyle format can be set for a specific cell, for a row, for a column or for a range of cells. Setting a format for a cell overrides the format of a row or a column.

Setting the cell format can be accomplished from ExcelCell class using setStyle() method or other specific methods for formatting.

Setting the row format can be accomplished from ExcelRow class using setStyle() method or other specific methods for formatting.

Setting the column format can be accomplished from ExcelColumn class using setStyle() method or other specific methods for formatting.

Setting the format for a range of cells can be accomplished from ExcelTable class using easy_setRangeStyle() method.

For better performances, EasyXLS recommends using as less as possible instances of ExcelStyle classes and avoid setting the format attributes for each ExcelCell class. For more details check Export large Excel files chapter.

Source code sample

If you want to format cells, consider the code sample and the screen shot below:

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

The screen shot below represents the result of the above code that formats the cells. It shows an Excel file with two worksheets ('First Tab' and 'Second Tab'). The first worksheet has the following format for the cells. The column headers are formatted with font size (8), font name (Verdana), foreground (yellow), background (black), borders color (gray), border size (medium), horizontal alignment (center), vertical alignment (bottom), and wrap option. The table cells are formatted with default font size (10), default font name (Arial), borders color (gray), foreground color (dark gray).

Formatting cells

 
 

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:

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