Max

Max OP

I´ve seen it. But it seems more suited for xlsx file build from the ground up, not from a database query. But thanks.

0
Post #11
NobbZ

NobbZ

Well, even the csv isn’t build from a db query but from data.

Of course when spitting out excel you need to have more to do to bootstrap the file. Also excel spreadsheets are so much more powerful than plain csv. To be able to use this power in your export as well, of course the library needs to have a slightly more complex API than a CSV export.

0
Post #12
gregvaughn

gregvaughn

I have encountered this problem at a prior job. You’ll also find different behavior for different version of Excel and whether it is the Windows or Mac version. Here’s a very good summary of the problem and possible approaches: https://stackoverflow.com/questions/6002256/is-it-possible-to-force-excel-recognize-utf-8-csv-files-automatically

If I recall, what we did was offer the user to export as either .csv or .xls. The .xls was really html table markup filled with the data, but Excel recognized that and imported it as utf8. This approach is discussed in the link above, though not the accepted answer.

2
Post #13
gregvaughn

gregvaughn

This may be too much of a tangent, but since this question is really about Excel and not about Elixir, I don’t feel too bad. If you know Ruby, this is the code my co-worker extracted for doing that “html table inside a .xls file” approach. Even if you don’t know Ruby, the README has more background too. GitHub - livingsocial/excelinator: convert your csv data and html tables to excel data. · GitHub

2
Post #14
tallakt

tallakt

Check out my library codepagex on hex.pm. You shoul be able to convert between iso-___- and utf8 easily. Also in the readme of that package, mentioned some simpler built in erlang functions for the same functionality

0
Post #15
tallakt

tallakt

Just to mention what I think in general avout this stuff: convert to utf8 at the boundaries of your program. Ie. when reading or writing to csv files. Then stick to utf8 inside your system

0
Post #16
NobbZ

NobbZ

No need to convert anything. The problem is that the customers reader (Excel) does default to some iso-encoding and therefore can’t read utf8 encoded CSV properly. The OPs system does already use utf8 internally completely as he describes.

Converting UTF8 to iso before writing isn’t a solution either, due to the possible loss of information.

0
Post #17
Tallak_Tveide

Tallak_Tveide

In my experience Excel doesnt generate utf8 csv files

Sendt fra min telefon

0
Post #18
NobbZ

NobbZ

Excel isn’t used as Writer/Generator, but as a Reader in this case…

0
Post #19
svsdehh

svsdehh

have you tried starting the file with a utf8 BOM? We are using a BOM at the start of the csv export file and excel is correctly recognizing the char set as uft8 and is therefore displaying all umlauts as it should.

see: Byte order mark - Wikipedia

0
Post #20