Excel file corrupted when exported using Excel Export Filter

Posted by: dyousef on 16 February 2021, 10:53 am EST

    • Post Options:
    • Link

    Posted 16 February 2021, 10:53 am EST

    I’m using Active Reports 15 to export a code based section report to xlsx in .net MVC.

    I use the following code to do that which exports a .xlsx file but when I open it in Excel I get a “We found a problem with some content in Report.xlsx. Do you want us to try recover as much as we can?” error.

    If I press yes the file opens in Excel with this message “Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.”

    
    Response.Buffer = true;
    Response.ClearContent();
    Response.ClearHeaders();
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                                  
    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.AddHeader("content-disposition", "attachment;fileName=Report.xlsx");
    var export = new XlsExport();
    export.FileFormat = FileFormat.Xlsx;
    
    var memStream = new MemoryStream();
    export.Export(theReport.Document, memStream);
                    
    Response.BinaryWrite(memStream.GetBuffer());
    Response.End()
    
    
    
  • Posted 17 February 2021, 2:24 pm EST

    Hello,

    In my understanding, you have some overlap control in your report that’s why you are facing this kind of issue. Could you please adjust the control and try again. If you don’t have any overlapping control then can you share the stripped report so that I can able to replicate the solution and help you accordingly.

    Thanks,

    Mohit

  • Posted 18 February 2021, 8:18 am EST

    Hi Mohit,

    Thanks for the help, I dont think I have any overlapping controls - you can download the code here https://drive.google.com/file/d/14LfGsNpOCBzoEyETXJ6BPRWZgo31SpGq/view?usp=sharing

  • Posted 20 February 2021, 8:39 pm EST

    Hello,

    Please use the following line of code:

    ```

    Response.BinaryWrite(memStream.ToArray());

    Thanks,
    Mohit
  • Posted 22 February 2021, 10:41 am EST

    Thanks Mohit for finding that! That does solve my problem.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels