I have a scenario, where i have a storage Blob which will have the Excel file, so in code level there is no Physical File path i have, so its Stream of file i will get the code. I need to Convert the same to CSV & push it back to the storage.
Tried below:-
Tried with
Microsoft.Office.Interop.Excel
Excel.Application app = new Excel.Application(); app.DisplayAlerts = false; // Open Excel Workbook for conversion. Excel.Workbook excelWorkbook = app.Workbooks.Open(sourceFile); // Save file as CSV file. excelWorkbook.SaveAs(destinationFile, Excel.XlFileFormat.xlCSV);
Issue:- in the SourcePath , i don't have a physical location, and moreover there is no overload seems to take Byte or stream of file.
Tried
https://github.com/youngcm2/CsvHelper.Excel
, Demo code as follows.using var reader = new CsvReader(new ExcelParser(FileContent, "JOB STATUSES", new CsvConfiguration(CultureInfo.CurrentCulture)));
Tried Below code even:-
using var parser = new ExcelParser(FileContent,CultureInfo.InvariantCulture); using var reader = new CsvReader(parser);
But here the ExcelParser is failing with Corrupterdfile with a valid CSV
:(
Issue:- Here although there is a OverLoad to pass the Stream but is critical in my case. As there is no specific file format i have. It can be any Random EXCEL file. There no Specific class i can define.
I am missing something , can anyone help on this.
Scenario in my case:-
- No Physical path to the File location . it's in Storage account, so Stream/Byte .
- EXCEL File can be of any number of rows or columns no Fixed Model i can have but single sheet.