diff --git a/web/server/vue-cli/src/components/Statistics/Guideline/GuidelineStatistics.vue b/web/server/vue-cli/src/components/Statistics/Guideline/GuidelineStatistics.vue index cef3904fb7..023737d015 100644 --- a/web/server/vue-cli/src/components/Statistics/Guideline/GuidelineStatistics.vue +++ b/web/server/vue-cli/src/components/Statistics/Guideline/GuidelineStatistics.vue @@ -313,6 +313,20 @@ function checker_stat(stat) { function downloadCSV() { const _values = []; statistics.value.forEach(stat => { + if (!stat.checkers.length) { + _values.push([ + stat.guidelineName, + stat.guidelineRule, + stat.guidelineRuleTitle, + "", + "", + "", + "", + "" + ]); + return; + } + stat.checkers.forEach(checker => { const _value = [ stat.guidelineName, diff --git a/web/server/vue-cli/src/composables/useToCSV.js b/web/server/vue-cli/src/composables/useToCSV.js index 9913923965..9ccab9280b 100644 --- a/web/server/vue-cli/src/composables/useToCSV.js +++ b/web/server/vue-cli/src/composables/useToCSV.js @@ -1,4 +1,10 @@ export function useToCSV() { + function escapeCSVField(value) { + const _str = value === null || value === undefined ? "" : String(value); + + return `"${_str.replaceAll('"', '""')}"`; + } + /** * Exports the given data with the given file name. * @param {Array.>} data - csv data. The first item is the @@ -6,7 +12,9 @@ export function useToCSV() { * @param {string} fileName - default file name for export. */ function toCSV(data, fileName) { - const _content = data.map(_d => _d.join(",")).join("\n"); + const _content = data + .map(_d => _d.map(_field => escapeCSVField(_field)).join(",")) + .join("\n"); const _csvContent = `data:text/csv;charset=utf-8,${ encodeURIComponent(_content)}`;