开发者

Generating Excel from C# - How to make diagonal borders?

开发者 https://www.devze.com 2022-12-08 01:27 出处:网络
I am using C# to generate an Excel spreadsheet and saving it in Excel 2003 XML format using this library. I need to make a cell that contains a big X. The sample sent by the client uses a left and rig

I am using C# to generate an Excel spreadsheet and saving it in Excel 2003 XML format using this library. I need to make a cell that contains a big X. The sample sent by the client uses a left and right diagonal border to accomplish this.

I've have been unable to find the correct code syntax to set a cell's style in this manner. How is this done?

Here is ho开发者_开发知识库w it is supposed to look:

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


in XML saved from Excel it appears 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"/>
    ...

I don't know this library but I've seen that you can define cell's borders using XmlStyle class, specially setting the Border.Sides property:

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;

thought may be this will help if you haven't tried.

0

精彩评论

暂无评论...
验证码 换一张
取 消