0

文档http://www.filehelpers.com/example_progress.html说我需要使用方法SetProgressHandlerExcelStorage没有它。

ExcelStorage有方法public event EventHandler<ProgressEventArgs> Progress; 所以看起来我需要以某种方式使用它?

ExcelStorage provider = new ExcelStorage(typeof(MyModel));

provider.StartRow = 2;    
provider.StartColumn = 1;                
provider.FileName = @"C:\Customers.xlsx";    
provider.HeaderRows = 13;

provider.InsertRecords(data.ToArray()); // need to get progress here

可能有人可以帮忙吗?

4

1 回答 1

2

尝试这个:

provider.Progress += provider_Progress;

然后定义provider_Progress要更新的事件处理程序

static void provider_Progress(object sender, ProgressEventArgs e)
{
     var percent = e.Percent; 
     var positionMax = e.TotalRecords; 
     var position = e.CurrentRecord; 

     // update the progress control

     Application.DoEvents(); 
}
于 2013-09-06T09:27:05.327 回答