Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions packages/plugin-import-export/src/export/createExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ export const createExport = async (args: CreateExportArgs) => {
columns: allColumns,
})

// Add UTF-8 BOM for Excel compatibility on Windows
if (isFirstBatch) {
this.push(new Uint8Array([0xef, 0xbb, 0xbf]))
}

this.push(encoder.encode(csvString))
} else {
// --- JSON Streaming ---
Expand Down Expand Up @@ -319,7 +324,7 @@ export const createExport = async (args: CreateExportArgs) => {
return new Response(stream as any, {
headers: {
'Content-Disposition': `attachment; filename="${name}"`,
'Content-Type': isCSV ? 'text/csv' : 'application/json',
'Content-Type': isCSV ? 'text/csv; charset=utf-8' : 'application/json',
},
})
}
Expand Down Expand Up @@ -403,7 +408,9 @@ export const createExport = async (args: CreateExportArgs) => {
)
}

const buffer = Buffer.from(format === 'json' ? `[${outputData.join(',')}]` : outputData.join(''))
const buffer = Buffer.from(
format === 'json' ? `[${outputData.join(',')}]` : '\uFEFF' + outputData.join(''),
)
if (debug) {
req.payload.logger.debug(`${format} file generation complete`)
}
Expand All @@ -415,7 +422,7 @@ export const createExport = async (args: CreateExportArgs) => {
req.file = {
name,
data: buffer,
mimetype: isCSV ? 'text/csv' : 'application/json',
mimetype: isCSV ? 'text/csv; charset=utf-8' : 'application/json',
size: buffer.length,
}
} else {
Expand All @@ -429,7 +436,7 @@ export const createExport = async (args: CreateExportArgs) => {
file: {
name,
data: buffer,
mimetype: isCSV ? 'text/csv' : 'application/json',
mimetype: isCSV ? 'text/csv; charset=utf-8' : 'application/json',
size: buffer.length,
},
user,
Expand Down
Loading