From 2da47e476d180452c3fd50beff43636e2a253157 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:55:45 +0000 Subject: [PATCH] fix(nc-gui): add encoding option in csv export --- .../nc-gui/extensions/data-exporter/index.vue | 93 +++++++++++++------ packages/nocodb/src/interface/Jobs.ts | 1 + .../jobs/data-export/data-export.processor.ts | 3 +- .../jobs/jobs/export-import/export.service.ts | 5 +- 4 files changed, 72 insertions(+), 30 deletions(-) diff --git a/packages/nc-gui/extensions/data-exporter/index.vue b/packages/nc-gui/extensions/data-exporter/index.vue index c383b4a8dd..43607d6949 100644 --- a/packages/nc-gui/extensions/data-exporter/index.vue +++ b/packages/nc-gui/extensions/data-exporter/index.vue @@ -94,8 +94,10 @@ const exportPayload = ref<{ tableId?: string viewId?: string delimiter?: string + encoding?: BufferEncoding }>({ delimiter: ',', + encoding: 'utf8', }) const tableList = computed(() => { @@ -166,6 +168,7 @@ async function exportDataAsync() { const jobData = await $api.export.data(exportPayload.value.viewId, 'csv', { extension_id: extension.value.id, delimiter: exportPayload.value.delimiter, + encoding: exportPayload.value.encoding, }) jobList.value.unshift(jobData) @@ -279,6 +282,7 @@ eventBus.on(async (event, payload) => { onMounted(async () => { exportPayload.value = extension.value.kvStore.get('exportPayload') || {} exportPayload.value.delimiter = exportPayload.value.delimiter || ',' + exportPayload.value.encoding = exportPayload.value.encoding || 'utf8' deletedExports.value = extension.value.kvStore.get('deletedExports') || [] @@ -411,33 +415,68 @@ onMounted(async () => { -
-
Separator
- - - -
- - - {{ delimiter.label }} - - -
-
-
-
+
+
+
Separator
+ + + +
+ + + {{ delimiter.label }} + + +
+
+
+
+
+
+
Encoding
+ + + +
+ + + {{ encoding.label }} + + +
+
+
+
+
{ this.logger.debug(e); diff --git a/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts b/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts index 06214a8059..dc59f6d9b3 100644 --- a/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts +++ b/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts @@ -461,6 +461,7 @@ export class ExportService { _fieldIds?: string[]; ncSiteUrl?: string; delimiter?: string; + encoding?: BufferEncoding; }, ) { const { dataStream, linkStream, handledMmList } = param; @@ -537,7 +538,7 @@ export class ExportService { const hasLink = !dataExportMode && mmColumns.length > 0; - dataStream.setEncoding('utf8'); + dataStream.setEncoding(param.encoding || 'utf8'); const formatData = (data: any) => { for (const row of data) { @@ -640,7 +641,7 @@ export class ExportService { } if (hasLink) { - linkStream.setEncoding('utf8'); + linkStream.setEncoding(param.encoding || 'utf8'); let streamedHeaders = false;