mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
XLSX export of active view / table Co-authored-by: Louis Delbosc <louis.delbosc.prestataire@anct.gouv.fr> Co-authored-by: Vincent Viers <vincent.viers@beta.gouv.fr>
This commit is contained in:
@@ -830,6 +830,16 @@ export class GristDoc extends DisposableWithEvents {
|
||||
}
|
||||
|
||||
public getCsvLink() {
|
||||
const params = this._getDocApiDownloadParams();
|
||||
return this.docPageModel.appModel.api.getDocAPI(this.docId()).getDownloadCsvUrl(params);
|
||||
}
|
||||
|
||||
public getXlsxActiveViewLink() {
|
||||
const params = this._getDocApiDownloadParams();
|
||||
return this.docPageModel.appModel.api.getDocAPI(this.docId()).getDownloadXlsxUrl(params);
|
||||
}
|
||||
|
||||
private _getDocApiDownloadParams() {
|
||||
const filters = this.viewModel.activeSection.peek().activeFilters.get().map(filterInfo => ({
|
||||
colRef : filterInfo.fieldOrColumn.origCol().origColRef(),
|
||||
filter : filterInfo.filter()
|
||||
@@ -841,8 +851,7 @@ export class GristDoc extends DisposableWithEvents {
|
||||
activeSortSpec: JSON.stringify(this.viewModel.activeSection().activeSortSpec()),
|
||||
filters : JSON.stringify(filters),
|
||||
};
|
||||
|
||||
return this.docPageModel.appModel.api.getDocAPI(this.docId()).getDownloadCsvUrl(params);
|
||||
return params;
|
||||
}
|
||||
|
||||
public hasGranularAccessRules(): boolean {
|
||||
|
||||
@@ -41,6 +41,8 @@ export function makeViewLayoutMenu(viewSection: ViewSectionRec, isReadonly: bool
|
||||
menuItemCmd(allCommands.printSection, 'Print widget', testId('print-section')),
|
||||
menuItemLink({ href: gristDoc.getCsvLink(), target: '_blank', download: ''},
|
||||
'Download as CSV', testId('download-section')),
|
||||
menuItemLink({ href: gristDoc.getXlsxActiveViewLink(), target: '_blank', download: ''},
|
||||
'Download as XLSX', testId('download-section')),
|
||||
dom.maybe((use) => ['detail', 'single'].includes(use(viewSection.parentKey)), () =>
|
||||
menuItemCmd(allCommands.editLayout, 'Edit Card Layout',
|
||||
dom.cls('disabled', isReadonly))),
|
||||
|
||||
Reference in New Issue
Block a user