Excel CSV export encoding

Solution 1:

I have found a blog post which outlines an Applescript solution to a similar problem. I've adapted it to your needs. Note that I haven't done any proper quoting of cell values or anything, it will need some tweaking to be more robust. It's also not the fastest solution in my minimal testing… but it's a start.

The key is write X to openFile as «class utf8»

tell application "Microsoft Excel"
    activate

    set outFile to (path of active workbook)
    set fileName to (name of active workbook)
    set outFile to (outFile & ":" & fileName & ".csv")
    set openFile to open for access file outFile with write permission
    set eof openFile to 0

    set lastCol to count of columns of used range of active sheet
    set lastRow to count of rows of used range of active sheet

    repeat with r from 1 to lastRow
        set rowStr to (value of cell r of column 1 of active sheet)
        repeat with c from 2 to lastCol
            set cellVal to (value of cell r of column c of active sheet)
            set rowStr to rowStr & "," & cellVal
        end repeat
        write rowStr & return to openFile as «class utf8»
    end repeat
    close access openFile    
end tell

Solution 2:

I found the easiest thing to do was to just let excel export to csv in its own dumb way, then open up a terminal and do the following:

iconv -t UTF8 -f MACROMAN < file.csv > file-utf8.csv