ahs10 Posted February 13, 2009 Share Posted February 13, 2009 so i am using fputcsv to create a csv file for to download. all works well except that utf-8 characters won't display properly in excel. however, the do display properly in numbers (apple's version of excel) and if i open the csv with text editor like bbedit, they display properly too. here's the header information i have in my php file. any ideas on how to get these characters (the ß character is the one i noticed) to display properly? header('Content-type: application/csv; charset=utf-8; name="' . $fileName . '.csv"'); header('Content-Disposition: attachment; filename="' . $fileName . '.csv"'); Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 13, 2009 Share Posted February 13, 2009 Use Unicode enabled font in Excel. Quote Link to comment Share on other sites More sharing options...
ahs10 Posted February 13, 2009 Author Share Posted February 13, 2009 thanks for your reply. that would make total sense, so i checked, but i am using a unicode enabled font in excel. if it helps to identify the problem, the ß is displayed as √ü any other ideas? Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 13, 2009 Share Posted February 13, 2009 Not sure... perhaps when you import CSV to Excel, you can specify the encoding? I'm pretty sure, that if two other programs show correct encoding, then the file itself is probably all right, and the issue lies somewhere in Excel. Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 13, 2009 Share Posted February 13, 2009 Ok. I just checked this with Excel 2007 Indeed, when you open a csv file with utf8 encoded characters, they come up as trash. It happens whether you double click the file, or open the fole from within Excel. However, if you import the data from the text file (it's in 'Data' ribbon, third from the left in my installation), you can select the encoding, and then it displays properly. Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted February 15, 2009 Share Posted February 15, 2009 all works well except that utf-8 characters won't display properly in excel.You could always try creating an actual Excel file rather than generating a CSV file for import into Excel. Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 15, 2009 Share Posted February 15, 2009 Mark: I suppose you can recommend some cool tool to do that. Am I right? Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted February 15, 2009 Share Posted February 15, 2009 Mark: I suppose you can recommend some cool tool to do that. Am I right? Given that I've just implemented the 256th (a nice round number for those of us who think in binary) out of the 352 (including Cube and Database) functions in MS Excel, which is a significant milestone (to myself at the very least) - I'm of a mind to trumpet the fruits of my labours. Quote Link to comment Share on other sites More sharing options...
ahs10 Posted February 16, 2009 Author Share Posted February 16, 2009 wow thanks guys... as long as i can pass it off as "not my fault" i'm good =) i figured it had to be something in excel since it opened up properly in bbedit. the phpexcel project is amazing! i might sign up to volunteer some code or time on that one. i thought thinking like that died with that pear project that was almost there.... it was so close too. thanks again, rock on! Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted February 16, 2009 Share Posted February 16, 2009 the phpexcel project is amazing! i might sign up to volunteer some code or time on that one. i thought thinking like that died with that pear project that was almost there.... it was so close too.Glad to be of service... and PHPExcel could always use more active support. If you'd like to volunteer, hop over to the web site and drop us a line. The core team is just three of us at the moment, and I'm about to go on a three month hiatus; but we have ambitious plans to introduce support for charts and pivot tables this year, not to mention improving the performance and reducing the memory overheads of the library. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.