diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/issues_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/timelog_controller.rb | 4 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 6 | ||||
-rw-r--r-- | app/helpers/timelog_helper.rb | 8 |
4 files changed, 6 insertions, 14 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 332734d16..f484ed82e 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -82,7 +82,7 @@ class IssuesController < ApplicationController render :template => 'issues/index.rhtml', :layout => !request.xhr? } format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") } - format.csv { send_data(issues_to_csv(@issues, @project).read, :type => 'text/csv; header=present', :filename => 'export.csv') } + format.csv { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') } format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') } end else diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index f53ea72fa..90abb1ebf 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -147,7 +147,7 @@ class TimelogController < ApplicationController respond_to do |format| format.html { render :layout => !request.xhr? } - format.csv { send_data(report_to_csv(@criterias, @periods, @hours).read, :type => 'text/csv; header=present', :filename => 'timelog.csv') } + format.csv { send_data(report_to_csv(@criterias, @periods, @hours), :type => 'text/csv; header=present', :filename => 'timelog.csv') } end end @@ -202,7 +202,7 @@ class TimelogController < ApplicationController :include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], :conditions => cond.conditions, :order => sort_clause) - send_data(entries_to_csv(@entries).read, :type => 'text/csv; header=present', :filename => 'timelog.csv') + send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv') } end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 0a55aa0f1..eb163e7c0 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -15,8 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'csv' - module IssuesHelper include ApplicationHelper @@ -146,8 +144,7 @@ module IssuesHelper def issues_to_csv(issues, project = nil) ic = Iconv.new(l(:general_csv_encoding), 'UTF-8') decimal_separator = l(:general_csv_decimal_separator) - export = StringIO.new - CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| + export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| # csv header fields headers = [ "#", l(:field_status), @@ -197,7 +194,6 @@ module IssuesHelper csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end } end end - export.rewind export end end diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index 178929161..01dcbb473 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -81,8 +81,7 @@ module TimelogHelper ic = Iconv.new(l(:general_csv_encoding), 'UTF-8') decimal_separator = l(:general_csv_decimal_separator) custom_fields = TimeEntryCustomField.find(:all) - export = StringIO.new - CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| + export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| # csv header fields headers = [l(:field_spent_on), l(:field_user), @@ -115,7 +114,6 @@ module TimelogHelper csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end } end end - export.rewind export end @@ -124,8 +122,7 @@ module TimelogHelper end def report_to_csv(criterias, periods, hours) - export = StringIO.new - CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| + export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| # Column headers headers = criterias.collect {|criteria| l(@available_criterias[criteria][:label]) } headers += periods @@ -144,7 +141,6 @@ module TimelogHelper row << "%.2f" %total csv << row end - export.rewind export end |