Introduction

The Cosmic XLSX plugin is a powerful client-side tool for Bubble web applications that allows you to generate and download complex, multi-sheet .xlsx files directly in the user's browser. It goes beyond basic CSV exports by enabling the use of Excel formulas, full cell and column styling, and the creation of multi-sheet workbooks. The plugin operates by building the file in a series of workflow steps, consuming data, applying formulas and styles, and finally triggering a download or uploading the file to your Bubble app's storage.

Element Setup

To begin, you must add the 📗 Excel Document element to your page. This element is invisible to the end-user and acts as a controller for all related workflow actions. All data and styling are assembled within this element before the final file is generated.

Exposed States

Exported file (file) Description: When using the "Download file" action with the "Just create link" option enabled, this state will hold the URL of the generated .xlsx file after it has been successfully uploaded to your Bubble app's file manager.


Events

File url generated Description: This event is triggered after the "Download file" action completes the file upload to your app's storage (when "Just create link" is set to "yes"). It signals that the Exported file state is now populated and the file URL is ready to be used in subsequent workflow steps.

Workflow Actions

The plugin's functionality is driven by a series of workflow actions. You will typically call them in sequence to build your document.

1. Add values to a Excel Document

Adds one or more values to a specified sheet, starting from a specific cell and extending in a given direction.Field NameTypeDescriptionSheet nametextThe name of the sheet where you want to insert values. If the sheet doesn't exist, it will be created.Starting celltextThe cell where the data insertion should begin (e.g., "A2").DirectionDropdownDefines whether the data should be inserted horizontally (Row) or vertically (Column).TypeDropdownThe data type of the values being inserted. Options are: Text, Number, Date, Boolean, Link.DatatextA list of values formatted as a single text string, separated by a delimiter.SeparatortextThe character or string used to separate values in the Data field. The default is a comma (,).

2. Add a formula to a Excel Document

Adds an Excel formula to a single cell or automatically extends it across a range of cells, adjusting cell references accordingly.Field NameTypeDescriptionSheet nametextThe name of the sheet where the formula will be added.Cell rangetextThe range of cells to apply the formula to (e.g., "C2:C100"). If a single cell is provided (e.g., "C2"), the formula will only be applied there.FormulatextThe Excel formula to apply. Write the formula as if it were for the first cell in the range (e.g., SUM(A2,B2)). The plugin will automatically adjust references for subsequent cells in the range.

3. Style cells of a Excel Document

Applies a rich set of visual styles to a specified range of cells.Field NameTypeDescriptionSheet nametextThe sheet where the styling will be applied.Cell rangetextThe range of cells to style (e.g., "A1:D1").Number formattextA valid Excel number format string (e.g., "0.00%", "dd/mm/yyyy", "$#,##0.00").Font sizenumberThe font size for the text within the cells.BoldbooleanSet to "yes" to make the text bold.UnderlinebooleanSet to "yes" to underline the text.ItalicbooleanSet to "yes" to make the text italic.Font colorColorThe color of the text.Cell backgroundColorThe background fill color for the cells.Vertical alignmentDropdownSets the vertical alignment of content (Top, Middle, Bottom).Horizontal alignmentDropdownSets the horizontal alignment of content (Left, Center, Right, Justify).Wrap textbooleanSet to "yes" to allow text to wrap onto multiple lines within a cell.Border colorColorThe color for all specified borders.Top/Left/Right/Bottom borderDropdownSets the style for each border individually (e.g., thin, medium, thick, dotted).

4. Format columns of a Excel Document

Applies formatting to entire columns within a sheet.Field NameTypeDescriptionSheet nametextThe sheet where the column formatting will be applied.Column nametextThe target column, specified by letter (e.g., "A") or number (e.g., "1").WidthnumberThe width of the column in Excel's character units (e.g., 15).HiddenbooleanSet to "yes" to hide the column from view.

5. Download file from a Excel Document