Sending an Exported Dashboard to the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.When the user exports a dashboard in the viewer, the result can be sent back to the server and saved, through the
Save the exported bytes in the event.
How it works. The exported file travels from the client viewer to the Python event, so exports can be stored server-side automatically.
onEndExportReport event.Save the exported bytes in the event.
def endExportReport(args: StiExportEventArgs):
filePath = os.path.normpath(os.getcwd() +
url_for('static', filename='reports/' + args.fileName))
with open(filePath, mode='wb') as file:
file.write(args.data)
return f'The exported dashboard was saved to {args.fileName}.'
viewer.onEndExportReport += endExportReportonEndExportReport— fires after an export;args.dataholds the document bytes andargs.fileNameits name.- Write
args.datato disk to archive every export on the server.
How it works. The exported file travels from the client viewer to the Python event, so exports can be stored server-side automatically.