Hi,
I create Excel files using Documents.Excel. In this process, I create Tables in the file and prepare TableStyles to make foratting easy and uniform. This works well:
var xlTableStyle = new WorksheetTableStyle("BR_Table"); //Table Header xlTableStyle.AreaFormats[WorksheetTableStyleArea.HeaderRow].Fill = CellFill.CreateSolidFill(Color.Black); xlTableStyle.AreaFormats[WorksheetTableStyleArea.HeaderRow].Font.Bold = ExcelDefaultableBoolean.True; xlTableStyle.AreaFormats[WorksheetTableStyleArea.HeaderRow].Font.ColorInfo = new WorkbookColorInfo(Color.White); //Row and Alternating ROw xlTableStyle.AreaFormats[WorksheetTableStyleArea.RowStripe].Fill =CellFill.CreateSolidFill(Color.Transparent); xlTableStyle.AreaFormats[WorksheetTableStyleArea.AlternateRowStripe].Fill = CellFill.CreateSolidFill(Color.Transparent); //Cell Borders; missing here: "insideVertocal", "insideHorozontal" xlTableStyle.AreaFormats[WorksheetTableStyleArea.WholeTable].BottomBorderStyle = CellBorderLineStyle.Thin; xlTableStyle.AreaFormats[WorksheetTableStyleArea.WholeTable].BottomBorderColorInfo = new WorkbookColorInfo(Color.Black); xlTableStyle.AreaFormats[WorksheetTableStyleArea.WholeTable].TopBorderStyle = CellBorderLineStyle.Thin; xlTableStyle.AreaFormats[WorksheetTableStyleArea.WholeTable].TopBorderColorInfo = new WorkbookColorInfo(Color.Black); xlTableStyle.AreaFormats[WorksheetTableStyleArea.WholeTable].LeftBorderStyle = CellBorderLineStyle.Thin; xlTableStyle.AreaFormats[WorksheetTableStyleArea.WholeTable].LeftBorderColorInfo = new WorkbookColorInfo(Color.Black); xlTableStyle.AreaFormats[WorksheetTableStyleArea.WholeTable].RightBorderStyle = CellBorderLineStyle.Thin; xlTableStyle.AreaFormats[WorksheetTableStyleArea.WholeTable].RightBorderColorInfo = new WorkbookColorInfo(Color.Black); xlwbkResultItems.CustomTableStyles.Add(xlTableStyle);
In further code, this TableStyle is applied:
var xlTable = xlRegionOfWorksheet.FormatAsTable(true); xlTable.Style = xlTableStyle;
The cell borders are not applied.... The 4 sides are set, but Excel offers additional "inside horizontal" and "inside vertical" lines:
How can I Access them?
Regards
Martin
Hello Martin,
I have been investigating into the behavior you are seeing, and it appears that you are correct that we do not expose the “inside horizontal” and “inside vertical” lines off of the AreaFormats collection of the WorksheetTable object. We do expose the ability to format each of the cells individually, though, and as such, I would recommend setting these properties that exist off of the WorksheetTableStyle.AreaFormats on the WorksheetCell.CellFormat instead.
I am attaching a sample project that uses your table style in conjunction with a CellFormat to achieve the requirement you are looking for. I hope this helps you.
If you would like to see inner borders implemented for table styles in the Infragistics for Windows Forms toolset, I would recommend suggesting a new product idea for this at our Windows Forms Ideas Site. This will place you in direct communication with our product management teams who plan and prioritize upcoming features and development based on community and user feedback.
Please let me know if you have any other questions or concerns on this matter.
ExcelTableStylingTest.zip
Hello Andrew,
thanks for your answer. Your Workaround solves my issue. I made a suggestion to the ideas site.
Case closed.
Thanks again