react-data-export icon indicating copy to clipboard operation
react-data-export copied to clipboard

Can't open files downloaded on Mac

Open refeals opened this issue 6 years ago • 4 comments

Hello! I'm using this library for a few days now without trouble on Ubuntu. The downloaded file opens correctly on my PC and Windows, but for some reason I get this error when trying to open the same file on a Mac:

“Excel could not open … because some content is unreadable”

I transferred the same file to my Ubuntu and it opens normally.

Has anyone gone through this? Maybe some encoding issue? I can't find anything on GitHub. I'm using version 0.4.2 and my code is pretty much the same as the example:

https://github.com/securedeveloper/react-data-export/blob/master/examples/with_custom_download_element.md

Thanks in advance!

refeals avatar Sep 19 '18 16:09 refeals

@refeals I'm also using MAC for development, also for testing. Can you please share the way you are producing the file, if possible also the excel file. Thanks.

securedeveloper avatar Oct 03 '18 16:10 securedeveloper

Since then I changed the way we're creating our files (backend is handling it) so I don't have an example anymore, but the file is as simple as you can get since it was just a first test version.

I tested it on a different Mac since the issue report with the same results.

The source is here:

import * as moment from 'moment'
import React, { Component } from 'react'
import ReactExport from "react-data-export"

const ExcelFile = ReactExport.ExcelFile
const ExcelSheet = ReactExport.ExcelFile.ExcelSheet
const ExcelColumn = ReactExport.ExcelFile.ExcelColumn

class DownloadExcel extends Component {
  render() {
    const invoices = this.props.invoices

    return (
      <div id="download-excel">
        <ExcelFile element={<button className="btn btn-info">Download Excel</button>} filename={`Faturas Aprovadas em ${moment().format("DD/M/YYYY")}`}>
          <ExcelSheet data={invoices} name={`Faturas Aprovadas em ${moment().format("DD/MM/YYYY")}`}>
            <ExcelColumn
              label="Fatura Líquida"
              value="calculation_with_currency"
            />
            <ExcelColumn
              label="Status"
              value="status"
            />
            <ExcelColumn
              label="Cliente"
              value="client"
            />
            <ExcelColumn
              label="Job"
              value="job"
            />
            <ExcelColumn
              label="País do Cliente"
              value="client_country"
            />
            <ExcelColumn
              label="Núm. Fatura"
              value="invoice_number"
            />
          </ExcelSheet>
        </ExcelFile>
      </div>
    )
  }
}

export default DownloadExcel

refeals avatar Oct 03 '18 16:10 refeals

Thanks, @refeals, will try with above structure and will get back to you with a valid solution (or at least the reason)

securedeveloper avatar Oct 03 '18 16:10 securedeveloper

I'm facing the same issue. Excel needs to be repaired since it has unreadable content error.

Pranav-Dakshina avatar Apr 01 '20 20:04 Pranav-Dakshina