Skip to content

Commit

Permalink
Allow exporting of CSVs from sheets. For ravel #200.
Browse files Browse the repository at this point in the history
  • Loading branch information
highperformancecoder committed May 14, 2024
1 parent 2edc31c commit 26096cc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ export class ContextMenuManager {
},
]
}),
new MenuItem({
label: 'Export as CSV',
click: () => {CommandsManager.exportItemAsCSV(sheet);}
}),
];
break;
default:
Expand Down
1 change: 1 addition & 0 deletions gui-js/libs/shared/src/lib/backend/minsky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@ export class Sheet extends Item {
async corners(): Promise<object[]> {return this.$callMethod('corners');}
async draw(a1: minsky__dummy): Promise<void> {return this.$callMethod('draw',a1);}
async drawResizeHandles(a1: minsky__dummy): Promise<void> {return this.$callMethod('drawResizeHandles',a1);}
async exportAsCSV(a1: string): Promise<void> {return this.$callMethod('exportAsCSV',a1);}
async inItem(a1: number,a2: number): Promise<boolean> {return this.$callMethod('inItem',a1,a2);}
async inRavel(a1: number,a2: number): Promise<boolean> {return this.$callMethod('inRavel',a1,a2);}
async onKeyPress(a1: number,a2: string,a3: number): Promise<boolean> {return this.$callMethod('onKeyPress',a1,a2,a3);}
Expand Down
7 changes: 7 additions & 0 deletions model/sheet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,10 @@ void Sheet::draw(cairo_t* cairo) const
cairo_clip(cairo);
}

void Sheet::exportAsCSV(const string& filename) const
{
if (!value)
throw_error("input not defined");
VariableValue vv(VariableType::flow); vv=*value;
vv.exportAsCSV(filename);
}
3 changes: 3 additions & 0 deletions model/sheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ namespace minsky
/// calculates the input value
void computeValue();

/// export the plotted data as a CSV file
void exportAsCSV(const std::string& filename) const;

bool showRavel=false;
ShowSlice showRowSlice=ShowSlice::head; ///< whether to elide rows from beginning, end or middle
ShowSlice showColSlice=ShowSlice::head; ///< whether to elide columnss from beginning, end or middle
Expand Down

0 comments on commit 26096cc

Please sign in to comment.