コード例 #1
0
        public static void SaveToExcel(this DataTable target, string filePath)
        {
            IWorkbook workbook = new HSSFWorkbook();
            ISheet    sheet    = workbook.CreateSheet(target.TableName);

            sheet.CreateRowHeader(workbook, target);
            sheet.CreateRowItem(workbook, target);

            using (FileStream objFS = new FileStream(filePath, FileMode.Create, FileAccess.Write))
            {
                workbook.Write(objFS);

                objFS.Flush();
                objFS.Close();
            }
        }