sam
sam

Reputation: 3511

VSTO diagonal line in an Excel cell

I am currently trying to find a way using VSTO in C# for Excel, to draw a diagonal line in a cell using C# code. But i can't find anyone on the web who even tried to do this.

Does anyone know how to achieve this ?

Thank you

(Excuse me for my bad english but it's not my language)

Upvotes: 2

Views: 811

Answers (2)

to StackOverflow
to StackOverflow

Reputation: 124696

You can manipulate borders as follows:

Excel.Range range = ... the cell(s) you want ...;

var border = range.Borders[Excel.XlBordersIndex.xlDiagonalDown];
border.Weight = Excel.XlBorderWeight.xlThin;
border.LineStyle = Excel.XlLineStyle.xlContinuous;

The XlBordersIndex enumeration specifies which border you want to update:

xlDiagonalDown
xlDiagonalUp
xlEdgeBottom
xlEdgeLeft
xlEdgeRight
xlEdgeTop
...

Upvotes: 4

user1429899
user1429899

Reputation: 288

I do not how in VSTO, but using COM you can do something like this:

ActiveSheet.Shapes.AddLine(BeginX, BeginY, EndX, EndY);

Upvotes: 0

Related Questions