Sto costruendo un'app console che sposta i dati in un file excel (utilizzando la libreria EPPlus). Sto salvando ExcelPackage come MemoryStream e desidero collegarlo a un'email. Tuttavia, quando ricevo l'email, il file Excel è vuoto - 0 byte.EPPlus con MemoryStream come allegato e-mail - il file è vuoto
Pensieri?
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();
}
Ecco il codice per creare l'allegato e-mail:
Attachment attachment = new Attachment(outputStream, "ECO_exceptions.xlsx", "application/vnd.ms-excel");
Grazie, post utile, se non troppo disturbo si prega di modificare in modo che package.Save(); è nella sezione USING. –