Browse Source

fix(nocodb): show the field data only for share view

pull/4848/head
Wing-Kam Wong 2 years ago
parent
commit
0a3effcbcc
  1. 12
      packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts

12
packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts

@ -28,16 +28,26 @@ async function exportExcel(req: Request, res: Response) {
}
const model = await view.getModelWithInfo();
await view.getColumns();
const { offset, dbRows, elapsed } = await getDbRows(model, view, req);
const fields = req.query.fields as string[];
const data = XLSX.utils.json_to_sheet(dbRows, { header: fields });
const data = XLSX.utils.json_to_sheet(
dbRows.map((o: Record<string, any>) =>
Object.fromEntries(fields.map((f) => [f, o[f]]))
),
{ header: fields }
);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, data, view.title);
const buf = XLSX.write(wb, { type: 'base64', bookType: 'xlsx' });
res.set({
'Access-Control-Expose-Headers': 'nc-export-offset',
'nc-export-offset': offset,

Loading…
Cancel
Save