public byte[] ConvertToZipFile(IEnumerable <TEntity> entities, string sheetName = "Sheet1", bool enableProfileLog = true)
        {
            var zipper = new ExcelZippedExporter();

            zipper.TemplateFileName = TemplateFileName;
            zipper.AddExport(sheetName, this, entities);
            zipper.EnableProfileLog = enableProfileLog;
            return(zipper.BuildZipFile());

            /*
             * if (string.IsNullOrEmpty(TemplateFileName)) {
             * using (ExcelPackage pck = new ExcelPackage()) {
             *  var ws = pck.Workbook.Worksheets.Add(sheetName);
             *  RenderWorkSheet(entities, ws);
             *  return ZipPackage(pck);
             * }
             * } else {
             * using (var fs = new FileStream(TemplateFileName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
             *  using (ExcelPackage pck = new ExcelPackage(fs)) {
             *    ExcelWorksheet ws = pck.Workbook.Worksheets.First(i => i.Name == sheetName);
             *    RenderWorkSheet(entities, ws);
             *
             *    var dataRange = ws.Cells["A1:" + ws.Dimension.End.Address.ToString()];
             *    // 刷新所有透视表
             *    foreach (var w in pck.Workbook.Worksheets) {
             *      foreach (var p in w.PivotTables) {
             *        p.CacheDefinition.SourceRange = dataRange;
             *      }
             *    }
             *
             *    return ZipPackage(pck);
             *  }
             * }
             * }*/
        }
        public async Task <byte[]> ConvertToZipFileSync(IEnumerable <TEntity> entities, string sheetName = "Sheet1", bool enableProfileLog = true)
        {
            var zipper = new ExcelZippedExporter();

            zipper.TemplateFileName = TemplateFileName;
            zipper.AddExport(sheetName, this, entities);
            zipper.EnableProfileLog = enableProfileLog;
            return(await zipper.BuildZipFileSync());
        }
        public void SetContentDispositionHeader(HttpResponseBase respose, string fileName = null, bool autoLimit = true)
        {
            if (autoLimit && HttpContext.Current != null)
            {
                // 检查是否有超时
                var  url   = HttpContext.Current.Request.RawUrl;
                bool exist = true;

                DataCache.GetOrDefaultBySession("export_report" + url, () => {
                    exist = false;
                    return("e");
                }, 30);

                if (exist)
                {
                    throw new Exception("报表导出请间隔30秒");
                }
            }
            // 增加TimeOut
            ExcelZippedExporter.SetContentDispositionHeader(respose, fileName);
        }