EasyXLS

Formatting cells, columns and rows

Concept

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.

Concept in action

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

Source code sample

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

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
.NET Excel Writer
.NET version to create and export Excel files
.NET Excel Reader
.NET version to read and import Excel files
-
Java
Java Excel Library
full Java version to import, export or convert Excel files
Java Excel Writer
Java version to create and export Excel files
Java Excel Reader
Java version to read and import Excel files
Download EasyXLS™ Excel Library for .NET and Java

File formats:

MS Excel 97 - 2003
MS Excel 2007 - 2010
MS Excel 2013
MS Excel 2016
MS Excel 2019
XLSX XLSM XLSB XLS
XML HTML CSV TXT