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>
This commit is contained in:
Zoltán Bedi
2023-01-24 10:43:44 +01:00
committed by GitHub
parent 92a750a732
commit 4167214e35
9 changed files with 149 additions and 11 deletions

View File

@@ -0,0 +1,12 @@
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;
});
}