更换工作表后如何保持公式有效?我的意思是 如何在删除和替换工作表时保留公式对工作表的引用? 但在 C#
using Excel = Microsoft.Office.Interop.Excel;
Excel.Application excelApp = new Excel.ApplicationClass();
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(connection.DataSource, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
foreach (Excel.Worksheet sh in excelWorkbook.Sheets)
{
if (sh.Name == SheetName || sh.Name == "_"+SheetName)
{
sh.Application.DisplayAlerts = false;
sh.Delete();
}
}
excelWorkbook.Save();
excelWorkbook.Close(true, excelWorkbook.FullName, null);
excelApp.Quit();
稍后我将调用同名的 SQL 命令“创建表”。所有公式都不起作用