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 ?
(Excuse me for my bad english but it’s not my language)
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;
XlBordersIndex enumeration specifies which border you want to update:
xlDiagonalDown xlDiagonalUp xlEdgeBottom xlEdgeLeft xlEdgeRight xlEdgeTop ...
I do not how in VSTO, but using COM you can do something like this:
ActiveSheet.Shapes.AddLine(BeginX, BeginY, EndX, EndY);