NPOI导出EXCEL C#(winform)版
/// <summary> /// DataTable导出到Excel文件 /// </summary> /// <param name="dtSource">源DataTable</param> /// <param name="strHeaderText">表头文本</param> /// <param name="strFileName">保存位置</param> public static void DataTableToExcel(DataTable dtSource, string strHeaderText, string strFileName) { using (MemoryStream ms = DataTableToExcel(dtSource...
NPOI创建多个sheet
借用NPOI来实现,要在同一Excel文件中创建多个sheet,只需要在同一个workbook中创建多个sheet即可。要注意的是,sheet的名字一定不能重复。下面是实现的代码: private void buttonTest_Click(object sender, EventArgs e) { HSSFWorkbook workBook = new HSSFWorkbook(); //ISheet sheetA = workBook.CreateSheet("sheetA"); //ISheet sheetB = workBook.CreateSheet("sheetB"); createSheet(workBook,"SheetA"); createSheet(workBook,"SheetB"); createSheet(workBook,"SheetC"); string path = Application.St...