Ejemplo n.º 1
0
        public static MemoryStream ToCsvMemoryStream(this DataTable dt, string currentUserName)
        {
            var temproaryFolder = CommUtils.CreateTemporaryFolder(currentUserName);
            var filePath        = Path.Combine(temproaryFolder, "Temporary.csv");

            ExcelUtils.WriteCsv(dt, filePath);

            var buffer = System.IO.File.ReadAllBytes(filePath);

            CommUtils.DeleteFolderAync(temproaryFolder);

            return(new MemoryStream(buffer));
        }
Ejemplo n.º 2
0
        public static MemoryStream ToExcelMemoryStream(DataTable table, string fileName, string userName)
        {
            var tempFolder   = CommUtils.CreateTemporaryFolder(userName);
            var tempFilePath = Path.Combine(tempFolder, fileName);

            ExcelUtils.TableToExcel(table, tempFilePath);

            var buffer = System.IO.File.ReadAllBytes(tempFilePath);

            CommUtils.DeleteFolderAync(tempFolder);

            return(new MemoryStream(buffer));
        }