开发者

AutoFill error in excel c#

The err开发者_如何学JAVAor statement says "Unable to get the AutoFill property of the Range class". However, AutoFill property is indeed in Range Class, as I checked. Does anyone know how to resolve this error? I have tried search in google, and there's no approperiate answer to this. Also I have tried convert the code in VBA, and it works fine in VB.

 using Microsoft.Office.Interop.Excel;
 Application.Range["H2"].Select();
 Selection.AutoFill(Destination: mdlAMain.xlApp.Range["H2", "H" + myRow],
                                         Type: XlAutoFillType.xlFillDefault);


How big is your range? These folks had issues with >65K items. Excel AutoFill problem

A guy over here ( http://www.excelforum.com/excel-programming/734596-auto-fill-column-in-a-table.html ) mentions using what would amount to "myRow = ActiveSheet.UsedRange.Rows.Count". That sounds like it's a count of rows rather than an absolute cell location.

Wish I could help more. I'd stick with the "AutoFill method of Range class failed" and google the heck out of that.


I don't really know C# very well, but sometimes constants cannot be referred to by name outside of the particular office app that they are native to. The type parameter should not be required as it is optional inside excel.

I think the

Type: XlAutoFillType.xlFillDefault 

is causing the issue, maybe try omitting the type parameter as excel should know what to do without it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜