Forum: Ruby on Rails RE: How to change CSV properties.....

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ross D. (Guest)
on 2006-05-18 11:29
(Received via mailing list)
CSV is a text based format and doesn't have the ability to set the font
style.

I've never tried this by you could set the response header to
application/vnd.ms-excel and output the text as a html table (setting
the filename to have a .htm extension).

Excel may manage to import the file and parse it correctly but I'd
consider it a longshot and if you get it working in one version of Excel
it may not work in others.

With a mime type of application/vnd.ms-excel Windows would normally
expect a .xl? file extension so you'd definitely be pushing the
boundries.  Internet Explorer may also look at the .htm extension on the
filename and just render the table itself.  In short it's a hack that
probably wont work, now and in the future, but you never know your luck.


send_data(myreportDataAsHTMLTable,
	:type => 'application/vnd.ms-excel; charset=iso-8859-1;
header=present;',
	:filename => 'invoicehistoryreportAsHTMLTable.htm', :disposition =>
'attachment')


Ross
This topic is locked and can not be replied to.