开发者

How do I obtain Excel objects for using as C#4 dynamic interop method call arguments?

I have a great time interop'ing with excel. It's a breeze... until I hit a brick wall.

This works like a charm.

dynamic excel = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application"); 

which allows stuff like

var headercell = excel.Cells(RowNumber,ColumnNumber);
headercell.Value = moddef.Name;
headercell.Orientation = -60;
headercell.Font.Color = 0x00AA00;
headercell.Interior.Color =0xCCCCCC;
headercell.Font.Size = 20;      
headercell.ClearComments();
开发者_运维百科headercell.Data = "Here we are LIVE with excel";

This is all nice and well because I thus far am only using simple types interacting with excel. However, I want to draw a border around a table.

var bottomright = headercell.Offset(height,width);  
var wholeSection = excel.Range(headercell,bottomright);
wholeSection.BorderAround(/*what goes in here??*/);

in the msdn article Range object members the BorderAround method displays some arguments to be passed in. Thus far, I have not had to reference the Excel interop assemblies. Do I have to reference it in order to create the BorderAround arguments or is there another general trick to how I should approach invoking methods requiring Excel type arguments?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜