将Excel工作表从一个工作簿移动到另一个工作簿 [英] Move excel worksheet from one workbook to another
本文介绍了将Excel工作表从一个工作簿移动到另一个工作簿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下语句用于将C#中的excel工作表从一个工作簿复制到另一个工作簿.它使用的是Miscrosoft.Office.Interopt.Excel(.NET 1.0),但我现在想将其转换为.NET 3.5,现在代码已损坏.我将如何转换此语句以与.net 3.5一起使用.顺便说一句,这是在ASP.net Web应用程序中.
the following statement was used to copy a excel worksheet in C#, from one workbook to another. It was using Miscrosoft.Office.Interopt.Excel (.NET 1.0) but I now want to convert it to .NET 3.5 the code is now broke. How would I convert this statement to work with .net 3.5. BTW this is in a ASP.net Web app.
wbkSource.Sheets("Source").Copy(wbk.Sheets(1)); Broke here!
该语句因此错误而失败
This statement fails with this error
Non-invocable member 'Microsoft.Office.Interop.Excel. Workbook.Sheets' cannot be used like a method.
推荐答案
尝试过,没有用.尝试了一下,它起作用了!反复试验.
Tried that, Didn''t work. Tried this and it worked! A trial and error guess.
wbk.Sheets.Copy(wbkSource.Sheets["Source"], Type.Missing);
这篇关于将Excel工作表从一个工作簿移动到另一个工作簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文