mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
12
public/app/core/utils/sheet.ts
Normal file
12
public/app/core/utils/sheet.ts
Normal 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;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user