Skip to content

Exporting Data to XLS/XLSX File Using Wizard Without Database Persistence #154

Answered by fraineralex
aIexnder asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @aIexnder,

To achieve this, you can create a wizard model to persist dynamic fields, then generate an Excel report using the xlwt library. Save the workbook to BytesIO, encode in base64, attach it to the wizard record, and return an action for the user to download.

Important

You need to instale the xlwt python library

For example:

1. Create the Excel Workbook and Worksheet:

  • Utilize the xlwt library to create the workbook and worksheet.
  • Set up column widths and styles, including making headers bold.
# Import necessary libraries
from xlwt import Workbook, easyxf
import base64
from werkzeug import urls
import io

# Define headers for the Excel sheet
headers = ['Header1', 'Header2', 'He…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aIexnder
Comment options

Answer selected by aIexnder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants