unsupported file on open

hi,

I've tried today upgrading from 22.1.39 to 28.2.11, and I cannot open an excel file anymore on spreadsheet control (ASP.NET MVC) : I get the "Unsupported file" error.

here's my code, unchanged from previous version :


JS

var spreadsheet = ej.base.getComponent(document.getElementById('spreadsheet'), 'spreadsheet');
fetch("/PointSingulier/GetExcelFile?filename=" + filename) // fetch the remote url
    .then((response) => response.json())
    .then((data) => {
        spreadsheet.openFromJson({ file: data });
    })


C# (copy/paste from your online example)

public string GetExcelFile(string filename)
{
    var basePath = HttpContext.Server.MapPath("~" + filename);
    var open = GetExcelFile(basePath, filename);
    return Workbook.Open(open);
}

public OpenRequest GetExcelFile(string basePath, string filename)
{
    ExcelEngine excelEngine = new ExcelEngine();
    IWorkbook workbook;
    FileStream fs = System.IO.File.Open(basePath, FileMode.Open);
    workbook = excelEngine.Excel.Workbooks.Open(fs, ExcelOpenType.Automatic);
    MemoryStream outputStream = new MemoryStream();
    workbook.SaveAs(outputStream);
    HttpPostedFileBase fileBase = new HttpPostedFile(outputStream.ToArray(), filename);
    HttpPostedFileBase[] files = new HttpPostedFileBase[1];
    files[0] = fileBase;
    OpenRequest open = new OpenRequest();
    open.File = files;
    fs.Close();
    return open;
}


for the record, it doesn't work with 24.2.9 either (I tried downgrading from 28 for testing purposes, with no positive results)

and when I go back to 22, it works again.


does someone have an idea ?

(excel file enclosed)


Attachment: TemplatePVVT_c3420ae6.zip

4 Replies

BP Babu Periyasamy Syncfusion Team March 19, 2025 02:26 PM UTC

Hi PAIN JOHNNY,


We have validated your reported issue based on the shared details and file. To investigate the issue, we have prepared an ASP.NET MVC application where we installed the latest Spreadsheet NuGet package (28.2.11) and referenced the client-side CDN package (version 28.2.11).


In the prepared application, we added a external button named "Open File from Server." When this button is clicked, this button triggers a fetch call to the server, passing the file name specified in your shared code snippet. We placed your shared file inside the Files folder of the application and added your shared code snippet in the Controller file for processing the file. Below is the code snippet used in the Controller and cshtml files.


Index.cshtml:

 

@Html.EJS().Button("export").Content("Open File from server").Click("openFile").Render()

 

function openFile() {

     var spreadsheet = ej.base.getComponent(document.getElementById('spreadsheet'), 'spreadsheet');

     var filename = "TemplatePVVT.xlsx";

     fetch("/Home/GetExcelFile?filename=" + filename) // fetch the remote url

         .then((response) => response.json())

         .then((data) => {

             spreadsheet.openFromJson({ file: data });

         })

}

 

Controller code:

 

public ActionResult GetExcelFile(string filename)

{

     var basePath = HttpContext.Server.MapPath("~/Files/" + filename);

     var open = GetFile(basePath, filename);

     return Workbook.Open(open);

}

 

public OpenRequest GetFile(string basePath, string filename)

{

     ExcelEngine excelEngine = new ExcelEngine();

     IWorkbook workbook;

     FileStream fs = System.IO.File.Open(basePath, FileMode.Open);

     workbook = excelEngine.Excel.Workbooks.Open(fs, ExcelOpenType.Automatic);

     MemoryStream outputStream = new MemoryStream();

     workbook.SaveAs(outputStream);

     HttpPostedFileBase fileBase = new HttpPostedFile(outputStream.ToArray(), filename);

     HttpPostedFileBase[] files = new HttpPostedFileBase[1];

     files[0] = fileBase;

     OpenRequest open = new OpenRequest();

     open.File = files;

     fs.Close();

     return open;

}

 

public class HttpPostedFile : HttpPostedFileBase

{

     private readonly byte[] fileBytes;

     public HttpPostedFile(byte[] fileBytes, string fileName)

     {

         this.fileBytes = fileBytes;

         this.InputStream = new MemoryStream(fileBytes);

         this.FileName = fileName;

     }

     public override int ContentLength => fileBytes.Length;

     public override string FileName { get; }

     public override Stream InputStream { get; }

}


We tested the application by launching it and attempting to open your shared Excel file using the button click. The file was processed correctly and imported into the Spreadsheet without any issues. We were unable to replicate the reported "Unsupported File" error.


For your convenience, we have prepared the output GIF file and attached below along with the prepared application.


Prepared sample (MVC application): https://drive.google.com/drive/folders/11lgC8HVnogm1yr9_b-lPnTwWKLbOqWfI?usp=sharing


Output:



Kindly check the above shared details and cross verify your application referring the above shared application. And if you are still facing the issue, please share the information below.


  1. Share the details of the .NET framework version that you are using.
  2. Share the .csproj file of your application to verify the dependent packages that are installed in your application.
  3. Also, if you have faced any exceptions while processing the file, please share those details.
  4. Share the video demonstration of the issue that you are facing.
  5. If possible, share a simple application to replicate your reported issue.


Please share the above requested details. Based on that, we will validate and update you with further details.


Please feel free to reach out if you have any concerns.


Regards,

Babu.



PJ PAIN JOHNNY March 19, 2025 03:15 PM UTC

thank you for this highly detailed answer.

I'll check this out and come back to you shortly.



PJ PAIN JOHNNY March 19, 2025 04:12 PM UTC

my bad !
your reply and attachmed solution were both helpful to me, as I understood that I didn't update every syncfusion package on my end (only licensing, spreadsheet and xlsio had been updated a).

it now works fine !

thanks a lot



BP Babu Periyasamy Syncfusion Team March 21, 2025 05:53 AM UTC

Hi PAIN JOHNNY,


We are delighted to hear that you are satisfied with the solution we have provided. If you have any further questions or need assistance, please contact us. We are here to help!


Regards,

Babu.


Loader.
Up arrow icon