請幫我在下面的代碼。我想將所有數據從「D:\ Data Validation_Source Code \ TestExcel \ DataValidationTest.xlsx」excel表單複製到「D:\ Data Validation_SourceCode \ TestExcel \ DataValidationTest - updated.xlsx」excel表單中,但不是將其複製到新的工作簿。請幫幫我。從一個Excel工作簿複製到另一個工作簿通過C#
try
{
string startPath = System.IO.Path.GetDirectoryName(
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
string filePath = System.IO.Path.Combine(startPath,
"D:\\Data Validation_Source Code\\TestExcel\\DataValidationTest.xlsx");
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(filePath);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkSheet.Copy(Type.Missing, Type.Missing);
xlWorkSheet = xlApp.Workbooks[2].Sheets[1];
}
finally
{
if (xlWorkBook != null)
{
xlWorkBook.Close();
}
if (xlApp != null)
{
xlWorkBook = xlApp.Workbooks.Open(
"D:\\Data Validation_SourceCode\\TestExcel\\DataValidationTest - updated.xlsx");
xlApp.Quit();
}
this.releaseObject(xlWorkSheet);
this.releaseObject(xlWorkBook);
this.releaseObject(xlApp);
}