Excel File of Type Xlsx. Cannot convert. The file is corrupt or damaged

Hi Team,
I am getting the error “Cannot convert. The file is corrupt or damaged.” when I try to convert my excel file (Xlsx) into the images.

The same file works fine when I try to read the file from local and convert it into images.
Sample Code:
using (Converter converter = new Converter(GetFileStream))
{
try
{
var info = converter.GetDocumentInfo();
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert(“converted.pdf”, options);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
static Stream GetFileStream() => File.OpenRead(filepath);

Now, as per my business use case, I am reading the same file from SharePoint using SharePoint REST API and getting the file content in the form of “Stream”. Passing the Stream to Convert class. It fails with the error “Cannot convert. The file is corrupt or damaged.”

Sample Code:
var byteArray = response.Content.ReadAsByteArrayAsync().Result;
using (var ms = new MemoryStream(byteArray))
{
var streams = new Dictionary<object, MemoryStream>();
SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.HideComments = true;
loadOptions.ShowHiddenSheets = false;
loadOptions.OnePagePerSheet = true;
loadOptions.Format = SpreadsheetFileType.Xlsx;

using (var converter = new Converter(() => ms, () => loadOptions))
{
    var options = new ImageConvertOptions
    {
        Format = ImageFileType.Png
    };
    converter.Convert(page => new MemoryStream(), (page, convertedStream, fileAnme) =>
    {
        var memoryStream = new MemoryStream();
        convertedStream.CopyTo(memoryStream);            
        streams.Add(page, memoryStream);
    }, options);
}

}

Note: The same code (without SpreadsheetLoadOptions) works fine for pptx,docx files reading from SharePoint.

Please help me with the excel file issue.

This topic has been moved to the related forum: Excel File of Type Xlsx. Cannot convert. The file is corrupt or damaged - Free Support Forum - groupdocs.com