0

I have implemented export to excel for ag grid with version "ag-grid-react": "^33.0.3". Now, when we download the excel we are getting this error: We found a problem with some content in Report.xlsx. Do you want us to try recover as much as we can? If you trust the source of this workbook, click Yes.

When we check the log it says:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<logFileName>error200280_01.xml</logFileName>
<summary>Errors were detected in file 'C:\Users\Filename.xlsx'</summary>
<repairedRecords>
<repairedRecord>Repaired Records: Cell information from /xl/worksheets/sheet1.xml part</repairedRecord>
</repairedRecords>
</recoveryLog>

Export to excel function:

function exportToExcel(props, fileName) {
    // Validate and format data before exporting
    const processCellCallback = (params) => {
        let value = params.value;
        if (value) {
            // Ensure value is a string and remove any invalid characters
            value = value.toString().replace(/[^\x20-\x7E]/g, '');
        }
    return value;    
    };

    const params = {
        processCellCallback: processCellCallback,
        fileName: fileName,
        sheetName: fileName,    
    };
    props.api.exportDataAsExcel(params);
}

Even if we simply do:

gridApi.exportDataAsExcel();

We are getting the same issue. Reference: https://www.ag-grid.com/examples/excel-export/excel-default-export/reactFunctional/

2
  • I think the issue here is with data which is making the spreadsheet corrupt. here is the link answers.microsoft.com/en-us/msoffice/forum/all/… which describes the similar problem. if you can post some demo code with data then it would be easier to help Commented Mar 11 at 20:00
  • Yes, the issue was with the date format which we were passing earlier for a specific date column. i.e. (MM/DD/YYYY). To fix this issue, we changed it to (YYYY-MM-DD). Commented Mar 17 at 10:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.