データをExcelファイルに移動するコンソールアプリケーションを構築しています(EPPlusライブラリを使用)。私はExcelPackageをMemoryStreamとして保存していますので、電子メールに添付します。ただし、電子メールを受け取ったとき、Excelファイルは空です(0バイト)。電子メール添付ファイルとしてMemoryStreamを持つEPPlus - ファイルが空です
思考?
MemoryStream outputStream = new MemoryStream();
using (ExcelPackage package = new ExcelPackage(outputStream)) {
// export each facility's rollup and detail to tabs in Excel (two tabs per facility)
ExcelWorksheet facilityWorksheet = package.Workbook.Worksheets.Add(row["facility_id"].ToString());
ExcelWorksheet facilityDetail = package.Workbook.Worksheets.Add(row["facility_id"].ToString() + "-detail");
facilityWorksheet.Cells.LoadFromDataTable(rollupData, true);
facilityDetail.Cells.LoadFromDataTable(rawExceptions, true);
package.Save();
}
はここで電子メールの添付ファイルを作成するためのコードです:
Attachment attachment = new Attachment(outputStream, "ECO_exceptions.xlsx", "application/vnd.ms-excel");
ありがとうございました。 USINGセクションにあります。 –