I am trying to use SetFontFormatting on a MergedCellsRegion and it does not work. I can use this just fine on an individual Cell as well as use SetFormatting without a problem. Should this work?
Yes, this should work. Can you post a small sample of the code so I can see the formatting you are setting and where the formatting object is coming from?
I was able to get this working with the following code.
oCellFont = oWorkbook:CreateNewWorkbookFont().
oCellFont:Name = "Arial".
oCellFont:Bold = Infragistics.Excel.ExcelDefaultableBoolean:
False.
oCellFont:
Height = 160 .
oMergedCellFormat = oWorkbook:CreateNewWorksheetCellFormat().
oMergedCellFormat:Alignment = Infragistics.Excel.HorizontalCellAlignment:LEFT.
oMergedCellFormat:ShrinkToFit = Infragistics.Excel.ExcelDefaultableBoolean:
TRUE.
oMergedCellFormat:FillPatternForegroundColor = System.Drawing.Color:LightGray.
oMergedCellFormat:FillPattern = Infragistics.Excel.FillPatternStyle:Solid.
oMergedCellFormat:FormatString =
"@".
oMergedCellFormat:
FONT:SetFontFormatting(oCellFont).
oIncrementRegion:CellFormat:SetFormatting(oMergedCellFormat).
Ok, I took your code and turned it into a small sample in C#. Here is my code:
Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets.Add("Sheet1"); IWorkbookFont oCellFont = workbook.CreateNewWorkbookFont(); oCellFont.Name = "Arial"; oCellFont.Bold = ExcelDefaultableBoolean.False; oCellFont.Height = 160; IWorksheetCellFormat oMergedCellFormat = workbook.CreateNewWorksheetCellFormat(); oMergedCellFormat.Alignment = HorizontalCellAlignment.Left; oMergedCellFormat.ShrinkToFit = ExcelDefaultableBoolean.True; oMergedCellFormat.FillPatternForegroundColor = System.Drawing.Color.LightGray; oMergedCellFormat.FillPattern = FillPatternStyle.Solid; oMergedCellFormat.FormatString = "@"; oMergedCellFormat.Font.SetFontFormatting(oCellFont); WorksheetMergedCellsRegion oIncrementRegion = worksheet.MergedCellsRegions.Add(0, 0, 1, 1); oIncrementRegion.CellFormat.SetFormatting(oMergedCellFormat); workbook.Save("Book1.xls");
And when I open the saved workbook, this is what I see:
So it appears this is now working. Try installing the latest SR to see if that fixes your issue.