Creating Excel with C # - How to make diagonal borders?

I use C # to create an Excel spreadsheet and save it in Excel 2003 XML format using this library . I need to make a cell containing a large X. The sample sent by the client uses the left and right diagonal borders to accomplish this.

I could not find the correct code syntax to set the cell style this way. How it's done?

Here's how it should look:

alt text http://preview.moveable.com/JM/ExcelBorders.gif

+3
source share
1 answer

in XML saved in Excel, it looks like this:

<Style ss:ID="s22">
   <Borders>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="DiagonalLeft" ss:LineStyle="Continuous" ss:Weight="1"/>
    ...

, , XmlStyle, Border.Sides:

XmlStyle sBorder = new XmlStyle();
sBorder.Border.Color = Color.Black;
sBorder.Border.Weight = 1;
sBorder.Border.LineStyle = Borderline.Continuous;
sBorder.Border.Sides = BorderSides.DiagonalLeft; //<-- here where I'm not sure!
                                                 //(I can't access the docs
                                                 // right now to check that Enum)

sheet[x, y].Style = sBorder;

, , .

+2

Source: https://habr.com/ru/post/1720200/


All Articles