Files
supabase/apps/studio/components/grid/components/header/Header.utils.ts
T
Joshen Lim 89140e7c08 Chore/support copy row in table editor (#37863)
* Support copy row in table editor

* Add copy action in Table Editor header
2025-08-13 09:51:04 +07:00

15 lines
476 B
TypeScript

import Papa from 'papaparse'
export const formatRowsForCSV = ({ rows, columns }: { rows: any[]; columns: string[] }) => {
const formattedRows = rows.map((row) => {
const formattedRow = row
Object.keys(row).map((column) => {
if (typeof row[column] === 'object' && row[column] !== null)
formattedRow[column] = JSON.stringify(formattedRow[column])
})
return formattedRow
})
const csv = Papa.unparse(formattedRows, { columns })
return csv
}