Exception when converting stream to workbook object

Hi team,
I have an api to upload and process an excel workbook. The file upload fails at any random try with the below exception (Logged in application insights) -
Message - This file’s format is not supported or you don’t specify a correct format.
Exception type - Aspose.Cells.CellsException

The same file gets successfully uploaded when trying to upload more than once.

Here is my code -

var filesReadToProvider = Request.Content.ReadAsMultipartAsync();

HttpPostedFile file= HttpContext.Current.Request.Files[0];
byte[] fileContents = new byte[file.ContentLength];
file.InputStream.Read(fileContents, 0,
file.ContentLength);
Stream fstream = new MemoryStream(fileContents);
Workbook workbook = new Workbook(fstream);

No exception is encountered in the local machine, it only happens in the deployed environments.

Thanks!

@VaniShrivastava,

I think this is not the issue with Aspose.Cells APIs rather your issue might be due to your environment or other configurations/settings. May be your underlying Excel file is not read properly into streams hence when you insatiate the Workbook object from streams, you got this error message. Please make sure that Excel file is read properly into streams before you create the Workbook object based on the stream. By the way, what is the file format type of Excel file, e.g. XLS, XLSX or CSV? If you still think your issue is due to Aspose.Cells APIs, kindly create a demo application (runnable), zip the project and post us here to reproduce the issue on our end, we will check it soon. Also, attach your template file in the zipped archive. Also give us your environment details.

Hi,
Thank you for looking into this.
As per your suggestions, I am trying to understand if there is any issue with stream and that it is read properly. Initially this was an intermittent issue but now it is failing for every upload. I will reach back to you if the issue still persists and also share zipped file so that you can share at your end.
File format - XLSM.

Thanks

@VaniShrivastava,
We look forward to your feedback.