I working on csharp and i need to replace file path
by memory stream
function below export data from data table to file path
but i need to export data table to memory stream
public void Export(DataTable dt, string module, string FilePath)
{
FileInfo file = new FileInfo(FilePath);
using (ExcelPackage pck = new ExcelPackage(file))
{
string sheetname = null;
sheetname = pck.Workbook.Worksheets.FirstOrDefault().Name;
if (sheetname == "Sheet1")
{
ExcelWorksheet ws = pck.Workbook.Worksheets.FirstOrDefault();
ws.Name = module;
ws.Cells["A1"].LoadFromDataTable(dt, false);
pck.Save();
}
else
{
if (module.Length > 30)
module = module.Substring(module.Length - 30, 30);
ExcelWorksheet ws = pck.Workbook.Worksheets.Add(module);
ws.Cells["A1"].LoadFromDataTable(dt, false);
pck.Save();
}
}
}
so how to do that please