Is there a way to simply read as excel file using MemoryStream
in C#? I am currently using the native microsoft library Microsoft.Office.Interop.Excel
. Is there a way that I could read a excel file with this library?
Opening a Excel file
using Microsoft.Office.Interop.Excel; // using this namespace
public ExcelHelper(string path)
{
_xlApp = new Application();
_xlWorkbook = _xlApp.Workbooks.Open(path);
}
Helper
public static MemoryStream DownloadFile(FtpHandler handler, FtpDirectoryOrFileDetail detail)
{
var fileByte = handler
.Download
.FileByPath(detail.FilePart.Filename, detail.SubFolderPath + "/", false)?.Data;
if (fileByte is null) return stream;
using (var fileStream = new MemoryStream(fileByte))
return fileStream;
return null;
}
The problem is that Open
extension seems using only a string
parameter and no option for MemoryStream
. Does anyone encounter this issue and able to fix this? I am very open to any suggestion.