dashbitco / nimble_csv

A simple and fast CSV parsing and dumping library for Elixir
https://hexdocs.pm/nimble_csv
767 stars 51 forks source link

Excel can not open files .xlsx and .xls #65

Closed programisti closed 3 years ago

programisti commented 3 years ago

'.xlsx' files generated by NimbleCSV has problems when opening on Mac via Excel and Numbers apps. They both throw this error

Excel cannot open the file '2021-04-01_invoices-2.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
Screen Shot 2021-07-19 at 8 35 44 PM

But if I change file extension to .xls then both Excel and Numbers apps are able to open it but they still throw warning/error message

Screen Shot 2021-07-19 at 8 37 32 PM

The file format and extension of '2021-04-01_invoices.xls' don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway?

NimbleCSV.Spreadsheet.dump_to_iodata(rows)

rows

[
  ["Wendy Ruecker", "Wendy Ruecker", "20210010000004321", ~D[2021-04-01],
   ~D[2021-04-30], "Stark Heights 2948", nil, "68204", "Lake Macie", "Plan",
   "Platinum Plan", nil, nil, 11900, 10000],
  ["Trever Ziemann", "Trever Ziemann", "2021001000000432100", ~D[2021-04-01],
   ~D[2021-04-30], "Nienow Mountains 1133", nil, "51534", "Lake Orval", "Plan",
   "Gold Plan", nil, nil, 9520, 8000],
  ["Domingo Ward", "Domingo Ward", "2021001000000432102", ~D[2021-04-01],
   ~D[2021-04-30], "Emmerich Greens 2", nil, "82765", "Kenneth", "Plan",
   "Silver Plan", nil, nil, 5950, 5000]
]
josevalim commented 3 years ago

Yes, you must use the .csv extension still, it is not a .xls file.

josevalim commented 3 years ago

I updated the docs in master but did a typo in the commit message. :)