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 MS Excel workbook.

Format using styles

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.

For better performances, EasyXLS recommends using as less as possible instances of ExcelStyle classes.

Setting the cell format can be accomplished from ExcelCell class using setStyle() method.

If you want to format cells, consider the code sample and the screenshot 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

Straight format for a cell

The format attributes can be set directly to the cell. Use this scenario if there are only a few cells that require different formatting than the rest of the cells.

For better performances, EasyXLS recommends avoiding setting the format attributes for each ExcelCell class and use styles instead. For more details check Export large Excel files chapter.
C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Format rows

Setting the row format can be accomplished from ExcelRow class using setStyle() method. Also, the row can be directly formatted using the specific methods from ExcelRow class.
C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

If a cell is defined in the ExcelTable, the cell format will override the format of the row. The empty cells from the row will keep the row formatting.

Format columns

Setting the column format can be accomplished from ExcelColumn class using setStyle() method. Also, the column can be directly formatted using the specific methods from ExcelColumn class.
C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

If a cell is defined in the ExcelTable, the cell format will override the format of the row. The empty cells from the row will keep the row formatting.

Format cell ranges

EasyXLS provides methods for applying a formatting style to a specific range of cells. Using ExcelTable.easy_setRangeStyle method, the same formatting is applied for all cells in the range.
C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Autoformat for cell ranges

EasyXLS provides methods to apply a complex layout format for a range of cells. The autoformat includes formatting for header, inner data, footer and margins.

Multiple formatting in cell

Using EasyXLS you can apply different font formatting in the same cell, so that the texts inside the cell have different look including bold, italic, colors, underline and other settings.

Format using themes

EasyXLS allows you to format the cells according to the theme set for the Excel file. The look of the spreadsheet changes according to the applied theme.

 
 

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