开发者

Get UsedRange with Late Binding

i am trying to use Late Binding to my App work in any PC with any version of the Excel.

So i was reading and trying to implement the examples i saw, but this is so confusing.

I create the instance successfully and open file succesfully, but how i get开发者_如何学C the UsedRange?

My code:

object excelApp;
object book;
object usedrange;

excelType = Type.GetTypeFromProgID("Excel.Application");
excelApp = Activator.CreateInstance(excelType);


object docs = excelApp.GetType().InvokeMember("Workbooks",
    BindingFlags.GetProperty, null, excelApp, null);


object[] parms = { "C:\\ABC", Missing.Value, true };
book = docs.GetType().InvokeMember("Open",
    BindingFlags.InvokeMethod, null, docs, parms);


object[] params2 = { "UsedRange", Missing.Value };
usedrange = book.GetType().InvokeMember("Range",
    BindingFlags.GetProperty, null, book, params2);

And then how i can get a row and then Cell by Cell?

Thanks in advance!


Try LateBindingApi.Excel: http://excel.codeplex.com

Same syntax like early bind but its latebind.


Use the Excel.Interop api. Example here: http://www.dotnetperls.com/excel.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜