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
> -----Original Message-----
> From: rails-bounces@lists.rubyonrails.org
> [mailto:rails-bounces@lists.rubyonrails.org]On Behalf Of
> venkat yejarla
> Sent: Thursday, 18 May 2006 2:33 PM
> To: rails@lists.rubyonrails.org
> Subject: [Rails] How to change CSV properties.....
>
>
> Hello Good morning to all,
>
>
> I am doing reports in ruby on rails,i am trying to export
> data throgh
> excel in CSV format.Now i want to set the font to the text
> exported to
> excel sheet.How can i set font..please help me regarding this ...
>
>
> my sample code was like this...
>
> report = StringIO.new
> CSV::Writer.generate(report, '','') do |csv|
> csv << [''Invoice History List'']
> csv <<
[nil,"#{((@start_date).to_s).gsub(''-'',''/'')}"]
> csv << [nil]
> end
>
> report.rewind
> send_data(report.read,
> :type => ''text/csv; charset=iso-8859-1;
header=present;'',
> :filename => ''invoicehistoryreport.csv'', :disposition
> => ''attachment'')
>
>
>
>
> please help me regarding this issue...
> --
> Posted with http://DevLists.com. Sign up and save your mailbox.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Multimedia MIME Reference.URL
Type: application/octet-stream
Size: 74 bytes
Desc: Multimedia MIME Reference.URL
Url :
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060518/f9b9b47c/MultimediaMIMEReference.obj