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");
When I apply the "SetFormatting" code you have listed in your example above (albeit aimed at WPF) using the Silverlight Infragistics.Excel library, the formatting does not get applied. Although I can see this custom style in the list of styles available to the worksheet, the text in the cell A1 does not have this style applied. Please advise.
Hello Andy99,
The behavior you are describing is caused by a known issue that we have already fixed internally and will be included in our next service releases. For further reference about the expected dates of the next service releases you can check the following link:
http://es.infragistics.com/support/service-releases.aspx#ServiceReleases
Please let me know if you have any further questions or concerns on that matter.