Calendar

<<  août 2008  >>
lumamejevesadi
28293031123
45678910
111214151617
181920222324
25262728293031
1234567

View posts in large calendar
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

(mars 30, 2008 17:01)

We have seen here in a previous post how to set some values in cell. We'll see now how to format the cells.

The examples shown here are quite simple but as all - or so - properties methods take only objects and that the MSDN gives only sparingly the real type to use.

Note that for all the following examples and to focus on the different types we can use, I have defined two aliases :

using TExcel = Microsoft.Office.Tools.Excel;

using IExcel = Microsoft.Office.Interop.Excel;

How to set some basic properties :

//IExcel.Range cell = ...

cell.Font.Bold = true;

cell.HorizontalAlignment = IExcel.XlHAlign.xlHAlignCenter;

cell.VerticalAlignment = IExcel.XlVAlign.xlVAlignCenter;

cell.WrapText = true;

How to set the width on a column :

cell.ColumnWidth = 10;

Note that here, the width is given in points.

How to set the formatting display on a cell :

How to find the correct formatting cell ? Well you can see in Excel directly in the cell format dialog editor. In the "custom" tab you will see some examples of the string you can give.

cell.NumberFormat = "0.00";

cell.NumberFormat = "#.##0.00";

cell.NumberFormat = "dd/MM/yyyy";

Billets liés

Ajouter un commentaire


 

  Country flag





Live preview

août 28. 2008 17:20

Powered by BlogEngine.NET 1.2.0.0 | Theme by Pierre-Emmanuel Dautreppe