/// <summary> /// Скачать сформированный файл *.eml /// </summary> public void DownLoad(IResponse response) { string emlFilePath = GetFilePath(); if (emlFilePath != null && response != null) { response.Clear(); response.ContentType = "text/plain"; response.Charset = "UTF-8"; response.AppendHeader("Content-Disposition", "attachment; filename=newsupplier.eml"); response.WriteFile(emlFilePath); } }
public static void ToResponse(IResponse response, Worksheet worksheet) { response.Clear(); response.AppendHeader("Content-Disposition", String.Format("attachment; filename=\"{0}\"", Uri.EscapeDataString(String.Format("{0}.xls", worksheet.Name)))); response.ContentType = "application/vnd.ms-excel"; using (var stream = new MemoryStream()) { var book = new Workbook(); book.Worksheets.Add(worksheet); book.Save(stream); stream.Position = 0; stream.CopyTo(response.OutputStream); } }