Copy sheet from one workbook to another using NPOI in C#

北慕城南 提交于 2019-12-10 08:59:02

问题


I need to copy a sheet from one workbook to another. I am trying with the below code, but it is not working:

ISheet newSheet = wb.GetSheetAt(0).CopySheet("WeeklyReport");
string filePath = "billing_template2.xlsx";
XSSFWorkbook billingWorkbook;
using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
    billingWorkbook = new XSSFWorkbook(fs);
}

billingWorkbook.Add(newSheet);

where wb is the source workbook and billingWorkbook is my destination workbook.

Note: My destination workbook already had a sheet. I need to add the copied sheet after this one.

来源:https://stackoverflow.com/questions/31916943/copy-sheet-from-one-workbook-to-another-using-npoi-in-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!