目前我的Excel文件有兩張紙,一張標題爲「英文」,一張標題爲「法文」。更改受保護的工作表
我編程方式打開工作簿,我並沒有任何問題,編輯我的英語片。當我打開第二張紙時,出現以下錯誤:
The cell or chart you're trying to change is on a protected sheet. To make a change, unprotect the sheet. You might be requested to enter a password.
請問我應該如何編輯第二張紙?
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
Workbook wb = excel.Workbooks.Open(fileLocation);
ws1.Range["E5"].Value = StartDate;
ws1.Range["G5"].Value = EndDate;
Worksheet ws = wb.Worksheets.get_Item("French");
ws.Select(Type.Missing);
ws.Range["E5"].Value = StartDate; // <- Crashes here
ws.Range["G5"].Value = EndDate;
嗨@Mikegrann,這工作像一個絕對的魅力。感謝您的答覆。 – Master