change the file type .xlsx to .xls in react-export-excel third part library?

Viewed 2013

I have created an excel file using react-export-excel third-party library. But I need to create .xls file, not .xlsx file. So how to Configure them?

<ExcelFile element={<MDBIcon icon="file-excel" size="2x" className="green-text" />}>
        <ExcelSheet data={props.email} name="Employees">
            <ExcelColumn label="Email" value="Email" />
            <ExcelColumn label="Quota" value="Quota" />
        </ExcelSheet>
    </ExcelFile>
1 Answers

According to the docs on npm you can set the fileExtension prop to: "xls".

In your case you can do the following:

<ExcelFile
  element={<MDBIcon icon="file-excel" size="2x" className="green-text" />}
  fileExtension="xls"
>
  <ExcelSheet data={props.email} name="Employees">
    <ExcelColumn label="Email" value="Email" />
    <ExcelColumn label="Quota" value="Quota" />
  </ExcelSheet>
</ExcelFile>

This prop defaults to "xlsx". So that explains why you're getting your output with that extension.

Update:

The problem with this package is that it's a fork of react-data-export. So there aren't any issues on the fork and the react-data-export seems like it's not really being maintained.

So it might be worth considering using a different library to accomplish your goal.

It's also worth noting that the difference between XLS and XLSX might be the reason this would be difficult to accomplish.

A quick Google Search gives this:

There are differences in the XLSX and XLS formats created by Excel. While XLS files use a proprietary binary format, XLSX files use a newer file format referred to as Open XML.

This means that the XLS binary format actually belongs to Microsoft. This could mean that getting a legit solution to get XLS format over XLSX wouldn't be a free one.

I've done some research and can't find a single solution for React that will let you generate an XLS formatted Excel file. All of them generate in the format XLSX.

Related