Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
370
Documents.Excel: Cell borders in TableStyle
posted

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