Prev | Current Page 384 | Next

David Berube

"Practical Reporting with Ruby and Rails"

The division of the sum of the cost values and the
clicks value is the average. (Technically, what most people call the average is actually the
mean, and strictly speaking, this calculates the mean value.) The @avg_cost_per_click is
used to show the average cost per click of the entire campaign.
Finally, you get ready to display your report:
if @excel_view
headers['Content-Type'] = "application/vnd.ms-excel"
headers['Content-Disposition'] = 'attachment; filename="adwords_report.xls"'
end
end
end
The if statement checks if you are trying to generate the report in Excel format; if so,
it sends the appropriate headers that mark the file as being an Excel document. But
notice that no special action is taken to generate the report as an Excel document.
Chapter 4 showed how you can use the spreadsheet-excel gem to generate Excel
spreadsheets, and you could have used that technique here. However, this application
uses a very odd trick: you mark the application as having an Excel content-type header
(specifically, application/vnd.


Pages:
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
ciekawe zdania spa nad morzem kredyt samochodowy reklama internetowa teksty piosenek