# Formatting Cells

## Content



To format the cells of a book, complete the following steps:

1.  Add a reference to C1.WPF.Excel.dll or C1.Silverlight.Excel.dll and create a **C1XLBook**.
    
    ```csharp
    // Create a new workbook to be saved
    C1XLBook book = new C1XLBook();
    ```
    
2.  Add some content to the workbook, create a new style and apply the styles to the cells in the first column of the sheet.
    
    ```csharp
    // Create a new style
     XLStyle style1 = new XLStyle(book);
     style1.ForeColor = Colors.Yellow;
     style1.BackColor = Colors.Blue;
     style1.Format = "$ .00";
    // Add content and apply styles to cells in first column of sheet
      XLSheet sheet = book.Sheets[0];
            int i;
            for (i = 0; i <= 9; i++)
              {
                sheet[i, 0].Value = i + 1;
                sheet[i, 0].Style = style1;
               }
    ```
    
3.  Save and open the workbook.
    
    ```csharp
    // Save and open the file
    book.Save(@"C:\test.xls");
    System.Diagnostics.Process.Start(@"C:\test.xls");
    ```
    
    ![cell formatting](https://cdn.mescius.io/document-site-files/images/4e8fb55a-cee4-4e5b-a6f1-f4ba4ccbfde1/c1excel_graphics/image11_3.png)