Format Worksheet Cells in a Workbook
This article shows how to:
- Use styles to quickly format data.
- Format cells in rows and columns.
- Use borders and colors to emphasize data.
- Apply number formats to emphasize data.
- Use fonts and attributes to highlight data.
- Format data in a named range.
- Change data alignment and orientation.
- Set row height and column width.
The example project performs all of these tasks and provides developers with a detailed description of how to create a workbook, add data into and apply formatting using Aspose.Cells.
Data Formatting
Formatting is used to distinguish between different types of information and to display data clearly.
A format represents a style and is defined as a set of characteristics, such as fonts and font sizes, number formats, cell borders, cell shading, indentation, alignment and text orientation. Borders provide further ways to highlight information. A border is a line drawn around a cell or a group of cells.
Number formats also make data more meaningful. By applying different number formats, you can change the appearance of numbers without changing the number behind the appearance.
Aspose.Cells provides lets you draw borders around cells and ranges easily. It also lets you apply fonts and shade cells. The component is efficient enough that you can format a complete row or column, set alignments, wrap and rotate text in cells. Aspose.Cells further supports all number formats supported by Microsoft Excel.
This article shows how to create a console application in Visual Studio.Net that generates an annual sales report. The workbook is created from scratch, then data is inserted and the worksheet is formatted. We show how to create a simple console application which creates an Excel workbook (you can also use a template file), insert sales data into the first worksheet, format the data and save an Excel file.
Process
Below are the steps involved how to create a spreadsheet and format different cells in different rows and columns of a worksheet.
- Download and install Aspose.Cells:
- Download Aspose.Cells for .NET.
- Install it on your development computer.
- Create a project and add references:
- Start Visual Studio.Net.
- Create a new console application.
- Add a reference to Aspose.Cells, for example …\Program Files\Aspose\Aspose.Cells\Bin\Net1.0\Aspose.Cells.dll
- Add the following code to the project: