开发者

AutoFill error in excel c#

开发者 https://www.devze.com 2023-04-12 21:26 出处:网络
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

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

精彩评论

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