Пример #1
0
        public ActionResult ExcelDownloadNPOI <T>(IEnumerable <T> list, IEnumerable <ExcelGridModel> columnList, string fileName)
        {
            var       excelConfig = ConvertExcelGridModelToConfig(columnList, fileName);
            DataTable rowData     = list.ToDataTable(columnList.Select(i => i.name));
            //var streams = NpoiHelper.GetExcelFromDataTable(rowData, fileName);
            var streams = NpoiHelper.GetDataTableToMemory(rowData, columnList.Select(i => i.label), true);
            FileStreamResult FileNpoi = new FileStreamResult(streams, MIMEType.xlsx)
            {
                FileDownloadName = fileName
            };

            return(FileNpoi);
        }
Пример #2
0
        public ActionResult ExcelDownload <T>(IEnumerable <T> list, IEnumerable <ExcelGridModel> columnList, string fileName)
        {
            var       excelConfig = ConvertExcelGridModelToConfig(columnList, fileName);
            DataTable rowData     = list.ToDataTable(columnList.Select(i => i.name));
            var       streams     = NpoiHelper.ExcelStream(rowData, columnList.Select(i => i.label), true);

            //var streams = NpoiHelper.ExcelStream();
            //var streams = ExcelHelpers.OutAsToExcelToMemory(rowData);
            //var stream = ExportMemoryStream(rowData, excelConfig);
            return(new FileStreamResult(streams, MIMEType.xlsx)
            {
                FileDownloadName = fileName
            });
        }