问题
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