Example #1
0
        public void ExcelExportTest()
        {
            List <TestD> data = new List <TestD> {
                new TestD
                {
                    Id    = 1,
                    Name  = "张三",
                    IsMan = true,
                    Tc    = TestC.A
                },
                new TestD
                {
                    Id    = 2,
                    Name  = "里斯",
                    IsMan = false,
                    Tc    = TestC.B
                }
            };

            using var fs = new FileStream("TestD.xlsx", FileMode.Create);
            ExcelFactory.ExportExcel(data, ExcelType.xlsx, fs, "TestD");
        }
Example #2
0
 /// <summary>
 /// 导出EXCEL
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="Data">需要被导出的数据</param>
 /// <param name="Types">Excel类型</param>
 /// <param name="SheetName">工作表名称</param>
 /// <param name="stream">流</param>
 /// <param name="action">自定义导出</param>
 /// <param name="footer">页脚内容</param>
 /// <param name="DateFormat">时间格式</param>
 public static void ExportExcel <T>(IEnumerable <T> Data, ExcelType Types, string SheetName,
                                    Action <Stream> action, dynamic footer = null, Stream stream = null, string DateFormat = "yyyy-MM-dd") where T : class, new()
 {
     ExcelFactory.ExportExcel(Data, Types, SheetName, action, footer, stream, DateFormat);
 }