Hi everybody I''am working on a Rails app (using utf-8) in which I use the Spreadsheet gem to generate Excel files (.xls in my case). I ran into some issues when trying to write foreign characters to the generated Excel-File. The solution I found so far is to use Iconv like this: Iconv.conv(''ISO-8859-9'', ''utf-8'', some_string) This works fine with for example turkish or spanish special characters. However I cant figure out how to deal with japanese characters. My question is how do I have to use Iconv to encode the japanese characters so they will be correctly inserted into the Excel file. Also I would be interested in some background info on this problem ( namely generating office files and utf-8 ) since I honestly don''t really understand the whole issue Excel seems to have there. Thanks in advance for any kind of help and advice. jruby 1.5.0 rails 2.3.8 spreadsheet 0.6.4.1 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bernd Burned wrote in post #968564:> Hi everybody > > I''am working on a Rails app (using utf-8) in which I use the Spreadsheet > gem to generate Excel files (.xls in my case). > > I ran into some issues when trying to write foreign characters to the > generated Excel-File. > > The solution I found so far is to use Iconv like this: > Iconv.conv(''ISO-8859-9'', ''utf-8'', some_string) > > This works fine with for example turkish or spanish special characters.That makes no sense. If your data is already in UTF-8, then it shouldn''t need to be converted. It displays OK in your application? (BTW, the concept of "special character" is really not a useful one. There are just characters.)> However I cant figure out how to deal with japanese characters.Again, no conversion should be necessary.> > My question is how do I have to use Iconv to encode the japanese > characters so they will be correctly inserted into the Excel file. > > Also I would be interested in some background info on this problem ( > namely generating office files and utf-8 ) since I honestly don''t really > understand the whole issue Excel seems to have there. > > Thanks in advance for any kind of help and advice. > > jruby 1.5.0 > rails 2.3.8 > spreadsheet 0.6.4.1My advice is to take a different approach altogether. Microsoft Office documents generally do not play well with Web browsers, so IMHO they have no place in Web applications at all. I would suggest exporting the data in another format, such as CSV or PDF. If you can say more about what you''re using the Excel files for, I''ll be happy to offer alternative suggestions. However, even if you do need an Excel file, it may be worth generating it as HTML. It turns out that Excel supports a representation of its spreadsheets as extended HTML -- see http://www.c-sharpcorner.com/UploadFile/kaushikborah28/79Nick08302007171404PM/79Nick.aspx -- and this will probably be easier to have Rails generate correctly. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you Marnen for your reply I agree it doesn''t make a lot of sense to me either. But then again neither do japanese characters nor Microsoft documents. Yes the characters are displayed correct in the application. I am aware it should all just work fine without the Iconv workaround but it did the trick for the the turkish and the spanish characters. Anyway- thanks again! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Please quote when replying. Bernd Burned wrote in post #968615:> Thank you Marnen for your reply > > I agree it doesn''t make a lot of sense to me either. > But then again neither do japanese characters nor Microsoft documents.Japanese characters are just characters like any other. What about them doesn''t make sense?> > Yes the characters are displayed correct in the application.Is the application specifying UTF-8 in the generated HTML, or some other character set? (Check the <head> element.)> > I am aware it should all just work fine without the Iconv workaround but > it did the trick for the the turkish and the spanish characters.Then that implies that the characters are not in fact encoded as UTF-8 to begin with.> > Anyway- thanks again!Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Possibly Parallel Threads
- LDAP Account Manager 4.7 with nginx support released
- LDAP Account Manager 4.9 with usability and Self Service improvements released
- Git, Capistrano, Passenger, and Apache Questions
- Problem while export to xls using spreadsheet gem in rails for Server
- spreadsheet-like presentation gem?