Trying to load a xlsm file in the workbook using -->
Workbook.Load(fileStream);
Getting an exception - Invalid or unrecognized file format. (Parameter 'stream')
This is a dot net standard 2.0 project. The same line of code works fine in a .net framework 4.6 project.
Any ideas on what can be the issue ?
I even tried a one liner code Workbook.Load(fileStream); within a .net framework 4.6.1 app and a dot net core 3.1 app but the dot net core failed to fetch the xlsm file.
Hello,
Thank you for posting in our community.
In order to provide you with better and more accurate support, I will need some clarifications regarding your environment. Is your query about Ignite UI for MVC's Excel Engine on .NET Core version 2.0 or 3.1?
If this is not the case can you please share more details regarding your scenario? This information is going to be highly appreciated and helpful for determining how to proceed further.
Looking forward to hearing from you.
Sorry maybe i posted in the wrong location. I am just trying to load a file stream into the Infragistics workbook via the Workbook.Load(Filestream stream) function. And i am doing this in a dot net core 3.1 application using the latest package version 20.1.123 of the Infragistics.Web.Documents.Excel nuget package. But i am unable to load .xlsx and .xlsm files into the workbook and i end up getting an exception --> Invalid or unrecognized file format. (Parameter 'stream').
var client = new SftpClient("ConnString");client.Connect();using (client){if (client.Exists("filename.xlsm")){var fileContents = client.OpenRead("filename.xlsm");var workbook = Workbook.Load(fileContents);}}
Thank you for the provided information.
I have created and attached a sample trying to reproduce your issue. The excel file is loaded correctly as a file stream. Please test it on your side and let me know how it behaves.
If this is not an accurate demonstration of what you are trying to achieve, please feel free to modify it and send it back to me along with steps to reproduce.
0676.Sample.zip
The only difference that I have in my use case is that my stream is not created using a local file in my code repo rather its fetched from a sftp server. If you can set that up locally, you will be able to reproduce my error.
After further investigation, assuming the SSH.NET third-party library is used, the issue is in the OpenRead method. The workaround is to use a temporary file and the DownloadFile method of the library:
using (var client = new SftpClient(con)) { client.Connect(); using (FileStream fileStream = System.IO.File.Create(tempFilePath)) { client.DownloadFile(remoteDirectory, fileStream); workbook = Workbook.Load(fileStream); } System.IO.File.Delete(tempFilePath); client.Disconnect(); }