如何将三个Excel工作表放在一个工作簿下

发布于 2024-09-14 07:15:28 字数 37 浏览 12 评论 0原文

我有三个 Excel 工作表,我想将它们合并到一个工作簿下。

I have three Excel worksheets which I want to merge under a single workbook.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╰◇生如夏花灿烂 2024-09-21 07:15:28

如果您需要在 C# 中执行此操作,请查看将 Excel 文件合并为一个一些想法。

您将需要 Microsoft Excel Interop 库。我在 http://forums.asp.net/p/1457463/ 找到以下示例3498328.aspx

ApplicationClass excelApplicationClass = new ApplicationClass();
_Workbook finalWorkbook = null;
Workbook workBook = null;
Worksheet workSheet = null;
Worksheet newWorksheet = null;

// Open or create destination WorkBook
finalWorkbook = excelApplicationClass.Workbooks.Open("dest.xlsx", ...);

//Open the source WorkBook
workBook = excelApplicationClass.Workbooks.Open("src.xlsx", ...);

//Open the WorkSheet
workSheet = (Worksheet)workBook.Sheets[1];

int countWorkSheet = finalWorkbook.Worksheets.Count;

newWorksheet = (Worksheet)finalWorkbook.Sheets[countWorkSheet];
workSheet.Copy(Missing.Value, newWorksheet);   //Copy from src to destn

finalWorkbook.Save();
workBook.Save();

搜索 Excel.Workseet.Copy() 方法。这应该会让您沿着所需的代码路径前进。

祝你好运!

If you need to do this in C#, have a look at Merge Excel Files Into One for some ideas.

You will need the Microsoft Excel Interop library. I found the following example at http://forums.asp.net/p/1457463/3498328.aspx

ApplicationClass excelApplicationClass = new ApplicationClass();
_Workbook finalWorkbook = null;
Workbook workBook = null;
Worksheet workSheet = null;
Worksheet newWorksheet = null;

// Open or create destination WorkBook
finalWorkbook = excelApplicationClass.Workbooks.Open("dest.xlsx", ...);

//Open the source WorkBook
workBook = excelApplicationClass.Workbooks.Open("src.xlsx", ...);

//Open the WorkSheet
workSheet = (Worksheet)workBook.Sheets[1];

int countWorkSheet = finalWorkbook.Worksheets.Count;

newWorksheet = (Worksheet)finalWorkbook.Sheets[countWorkSheet];
workSheet.Copy(Missing.Value, newWorksheet);   //Copy from src to destn

finalWorkbook.Save();
workBook.Save();

Do a search for the Excel.Workseet.Copy() method. This should get you going down the needed code path.

Good luck!

罪#恶を代价 2024-09-21 07:15:28
  1. 一次打开所有工作簿
  2. 然后右键单击要复制的第一张工作表的名称,然后
  3. 到书下拉列表中选择移动或复制... -向下选择您要复制到的书籍 勾选
  4. 创建副本 的框
  5. 确定
  6. 对另外 2 张重复步骤 2-5
  1. Open all of the workbooks at once
  2. Then right-click on the name of the first sheet you wish to copy and choose Move or Copy...
  3. In the To book drop-down select the book you wish to copy to
  4. Tick the box that says Create a copy
  5. Press OK
  6. Repeat steps 2-5 for the other 2 sheets
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文