public void SqlReport_Test()
        {
            SqlToExcel sqlExcel = new SqlToExcel(_baraMapper);
            //var result = _baraMapper.QueryBySql("Select * from T_Test", null);
            var dataReader = sqlExcel.QueryDataSetBySql("Select * from T_Test", null);
            var memStream  = sqlExcel.ReaderToExcel(dataReader);

            sqlExcel.SaveToFile(memStream, "test2.xls");
        }
Exemple #2
0
        public FileStreamResult Export(String ComandText, object reqParams)
        {
            SqlToExcel sqlExcel   = new SqlToExcel();
            var        dataReader = sqlExcel.QueryDataSetBySql(ComandText, reqParams);
            var        memStream  = sqlExcel.ReaderToExcel(dataReader);

            Response.Headers.Add("Content-Disposition", "attachment;fileName='SqlReport.xls'");
            //return FileStreamResult(memStream, "application/ms-excel", "fileStream.xls");
            return(File(memStream, "application/ms-excel"));
        }