grafana/public/app/core/utils/sheet.ts
Zoltán Bedi 4167214e35
Panel edit: Add feature to drag & drop spreadsheet files to the grafana datasource (#60586)
Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
Co-authored-by: Adela Almasan <adela.almasan@grafana.com>
2023-01-24 10:43:44 +01:00

13 lines
372 B
TypeScript

import { read, utils } from 'xlsx';
import { ArrayDataFrame, DataFrame } from '@grafana/data';
export function readSpreadsheet(file: ArrayBuffer): DataFrame[] {
const wb = read(file, { type: 'buffer' });
return wb.SheetNames.map((name) => {
const frame = new ArrayDataFrame(utils.sheet_to_json(wb.Sheets[name]));
frame.name = name;
return frame;
});
}