Hello,
Can any one let me know how to apply excel cell styles? http://msdn.microsoft.com/en-us/library/f1hh9fza(v=VS.100).aspx
Are you interested in adding the workbook styles specifically or are you just looking for a way to set the style of cells? If you want to add workbook styles, you can do something like this:
Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets.Add("Sheet1"); IWorksheetCellFormat style = workbook.CreateNewWorksheetCellFormat(); style.Font.Name = "Verdana"; style.Font.Height = 240; style.Font.Color = System.Drawing.Color.Red; style.FillPatternForegroundColor = System.Drawing.Color.Gray; style.FillPattern = FillPatternStyle.Solid; workbook.Styles.AddUserDefinedStyle(style, "NewStyle"); WorksheetCell cell = worksheet.GetCell("A1"); cell.Value = "Test"; cell.CellFormat.SetFormatting(style); workbook.Save("Styles.xls");
But if you just want to change the style of a cell, you can do this:
Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets.Add("Sheet1"); WorksheetCell cell = worksheet.GetCell("A1"); cell.Value = "Test"; cell.CellFormat.Font.Name = "Verdana"; cell.CellFormat.Font.Height = 240; cell.CellFormat.Font.Color = System.Drawing.Color.Red; cell.CellFormat.FillPatternForegroundColor = System.Drawing.Color.Gray; cell.CellFormat.FillPattern = FillPatternStyle.Solid; workbook.Save("Styles.xls");
Thank you.
Can you please let me know how to apply "Conditional Cell formatting".. If the value is > 5 then I want to apply a style..
I am just checking have you been able to resolve your issue? If you still need any assistance on the matter do not hesitate to ask.
Conditional formatting is currently not supported. You can submit a feature request for this.