示例#1
0
        /// <summary>
        /// 将指定查询变为Excel导出,将不考虑分页,所以查出的数据量太大可能出问题 v0.2.0+
        /// </summary>
        /// <returns></returns>
        public async Task <FileResult> Export()
        {
            var key = (string)this.ControllerContext.RouteData.Values["key"];

            Log.ObjectId = key;
            var dict = Request.Query.ToDictionary(kv => kv.Key, kv => (object)kv.Value.FirstOrDefault());

            string fileName = (string)dict["filename"] ?? "导出.xlsx";
            var    result   = await _dg.GetExcelStreamAsync(key, dict);

            return(File(result, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName));
        }