[英](C# - Excel) How do I write a formula to a newly created column for each existing row?
[英]Which event should I fire in C# for programming a newly created excel file?
如果我們想在用戶點擊保存按鈕時觸發一個事件,我們使用 Globals.ThisAddIn.Application.WorkbookAfterSave += Application_WorkbookAfterSave;
類似地,當我們想在用戶打開保存的文件時觸發事件時,我們使用 Globals.ThisAddIn.Application.WorkbookOpen += Application_WorkbookOpen;
我的問題是,當用戶創建新文件但尚未保存時,我們應該使用哪個事件。 如果沒有這樣的事件,請告訴我無論如何要在用戶創建新的 excel 文件后立即完成我的一些編程任務。
看起來您對 Excel 中 Application 類的NewWorkbook事件感興趣。
((Excel.AppEvents_Event)Application).NewWorkbook += new Microsoft.Office.Interop.Excel.AppEvents_NewWorkbookEventHandler(ThisWorkbook_NewWorkbook);
// the event handler
void ThisWorkbook_NewWorkbook(Microsoft.Office.Interop.Excel.Workbook Wb)
{
MessageBox.Show("New workbook" + Wb.Name);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.