حدث التحميل في GridDesktop
Contents
[
Hide
]
حدث التحميل لـ GridDesktop
يوضح الكود العيني التالي كيفية استخدام أنواع من حدث التحميل لـ GridDesktop أثناء استيراد ملف. يرجى التحقق من ملف الإكسل العينة .
الملف محمي بكلمة مرور، أولاً نحاول فتحه بكلمة مرور خاطئة، ثم في نهاية المطاف في حدث FailLoadFile، نستخدم كلمة مرور صحيحة لفتحه.
الكود المثالي
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class loadingevent : basicForm | |
{ | |
public loadingevent() | |
{ | |
InitializeComponent(); | |
gridDesktop1.Width = 800; | |
gridDesktop1.Height = 800; | |
gridDesktop1.ShowImportMessage = false; | |
this.gridDesktop1.FailLoadFile += GridDesktop1_FailLoadFile; | |
this.gridDesktop1.FinishLoadFile += GridDesktop1_FinishLoadFile; | |
this.gridDesktop1.FinishCalculate += GridDesktop1_FinishCalculate; | |
this.gridDesktop1.BeforeLoadFile += GridDesktop1_BeforeLoadFile; | |
this.gridDesktop1.BeforeCalculate += GridDesktop1_BeforeCalculate; | |
gridDesktop1.ImportExcelFile(LoadingHelper.getTestFile("loading-event.xlsx"), "wrongpassword", null, true, true); | |
this.Text = " load event test"; | |
} | |
private void GridDesktop1_BeforeCalculate(object sender, Aspose.Cells.GridDesktop.WorkBookEvents args) | |
{ | |
string value = this.gridDesktop1.GetActiveWorksheet().Cells["B5"].StringValue; | |
this.gridDesktop1.GetActiveWorksheet().Cells["B5"].PutValue(value + " -> before calculate, \n"); | |
} | |
private void GridDesktop1_BeforeLoadFile(object sender, Aspose.Cells.GridDesktop.WorkBookEvents args) | |
{ | |
string value = this.gridDesktop1.GetActiveWorksheet().Cells["B5"].StringValue; | |
this.gridDesktop1.GetActiveWorksheet().Cells["B5"].PutValue(value + " -> before loadfile, \n"); | |
} | |
private void GridDesktop1_FinishCalculate(object sender, Aspose.Cells.GridDesktop.WorkBookEvents args) | |
{ | |
string value = this.gridDesktop1.GetActiveWorksheet().Cells["B5"].StringValue; | |
this.gridDesktop1.GetActiveWorksheet().Cells["B5"].PutValue(value + " -> finish calculate, \n"); | |
} | |
private void GridDesktop1_FinishLoadFile(object sender, Aspose.Cells.GridDesktop.WorkBookEvents args) | |
{ | |
string value = this.gridDesktop1.GetActiveWorksheet().Cells["B5"].StringValue; | |
this.gridDesktop1.GetActiveWorksheet().Cells["B5"].PutValue(value + " -> finish loadfile, \n"); | |
} | |
private void GridDesktop1_FailLoadFile(object sender, String s) | |
{//try correct password | |
MessageBox.Show("fail load the file "+s+",now we try another password"); | |
gridDesktop1.ImportExcelFile(LoadingHelper.getTestFile("loading-event.xlsx"), "pwd456", null, false, true); | |
} | |
} | |
} |