OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Append BOM to ensure Excel can open CSV directly & correctly Encoding: UTF-8
Eric Guo93a0f13dd6d5
diff --git a/app/models/exports/concerns/csv.rb b/app/models/exports/concerns/csv.rbindex cc1c7b59e54..859e6e0ccaa 100644--- a/app/models/exports/concerns/csv.rb+++ b/app/models/exports/concerns/csv.rb@@ -53,7 +53,7 @@ module Exports::Exports::Result.new format: :csv,title: csv_export_filename,- content: serialized,+ content: "\xEF\xBB\xBF#{serialized}", # Make Excel open CSV happy by append UTF8 BOMmime_type: "text/csv"enddiff --git a/spec/models/projects/exporter/csv_integration_spec.rb b/spec/models/projects/exporter/csv_integration_spec.rbindex e578ab18bc6..11dcb17aa1d 100644--- a/spec/models/projects/exporter/csv_integration_spec.rb+++ b/spec/models/projects/exporter/csv_integration_spec.rb@@ -74,7 +74,7 @@ RSpec.describe Projects::Exports::CSV, "integration" doit "does not render project custom fields in the header" doexpect(parsed.size).to eq 2- expect(header).to eq ["id", "Identifier", "Name", "Description", "Status", "Public"]+ expect(header).to eq ["\xEF\xBB\xBFid", "Identifier", "Name", "Description", "Status", "Public"]endit "does not render the custom field values in the rows if enabled for a project" do@@ -93,7 +93,7 @@ RSpec.describe Projects::Exports::CSV, "integration" doexpect(cf_names).not_to include(not_used_string_cf.name)expect(cf_names).not_to include(hidden_cf.name)- expect(header).to eq ["id", "Identifier", "Name", "Description", "Status", "Public", *cf_names]+ expect(header).to eq ["\xEF\xBB\xBFid", "Identifier", "Name", "Description", "Status", "Public", *cf_names]endit "renders the custom field values in the rows if enabled for a project" do@@ -126,7 +126,7 @@ RSpec.describe Projects::Exports::CSV, "integration" doexpect(cf_names).to include(not_used_string_cf.name)expect(cf_names).to include(hidden_cf.name)- expect(header).to eq ["id", "Identifier", "Name", "Description", "Status", "Public", *cf_names]+ expect(header).to eq ["\xEF\xBB\xBFid", "Identifier", "Name", "Description", "Status", "Public", *cf_names]endit "renders the custom field values in the rows if enabled for a project" dodiff --git a/spec/models/work_package/exporter/csv_integration_spec.rb b/spec/models/work_package/exporter/csv_integration_spec.rbindex f2c0ef5e416..fb76f70c6b2 100644--- a/spec/models/work_package/exporter/csv_integration_spec.rb+++ b/spec/models/work_package/exporter/csv_integration_spec.rb@@ -124,7 +124,7 @@ RSpec.describe WorkPackage::Exports::CSV, "integration" dodata = CSV.parse instance.export!.contentexpect(data.size).to eq(5)- expect(data.pluck(0)).to eq ["Type", "Type A", "Type A", "Type A", "Type B"]+ expect(data.pluck(0)).to eq ["\xEF\xBB\xBFType", "Type A", "Type A", "Type A", "Type B"]endend@@ -171,7 +171,7 @@ RSpec.describe WorkPackage::Exports::CSV, "integration" dodata = CSV.parse instance.export!.contentexpect(data.size).to eq(5)- expect(data.pluck(0)).to eq %w[Subject WP4 WP2 WP1 WP3]+ expect(data.pluck(0)).to eq %w[WP4 WP2 WP1 WP3].unshift("\xEF\xBB\xBFSubject")endendend