> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prophecy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Excel

> Read and write Excel files

This page describes the **Excel-specific properties** that appear in the **Properties** tab of Source and Target gems. These settings are the same for Excel files regardless of which connection type is configured in the gem (for example, S3, SFTP, or SharePoint).

If you need details on configuring a Source or Target gem end to end (including all tabs such as **Location**), see the documentation for the specific file storage connection.

> [!NOTE]
>
> You can also use the [upload file](https://docs.prophecy.ai/data-analysis/gems/source-target/table/upload-files.md) feature
> to use Excel files. These will be stored in the SQL warehouse configured in your fabric.

## Properties

### Source properties

The following properties are available for the Excel Source gem.

| Property | Description | Default |
| - | - | - |
| Description | Description of the table. | None |
| Header | Whether the first row is the column header. | True |
| Allow Undefined Rows | Whether to permit rows with all values undefined (null or empty). | True |
| Allow Incomplete Rows | Whether to permit rows with missing values for some columns. | True |
| Ignore Cell Formatting | Whether to apply the number format for the cell value or get the raw value. | True |
| Sheet Reading method | Whether to read one sheet of data or union the data from multiple sheets into one table. Learn more in [Reading sheets](#reading-sheets). | Read single sheet data |
| Enter Cell Range | Range of cells to read, such as `A2:C5`. Leave empty to read the whole sheet. Can't be used with **Skip reading top n rows**. | None |
| Skip reading top n rows | Number of rows to skip at the top of each sheet. If **Header** is enabled, the first row after the skipped rows is the header. Otherwise, it's the first data row. Can't be used with **Enter Cell Range**. | `0` |
| Default column prefix | Prefix for generated column names when **Header** is disabled or a header cell is empty. Prophecy appends the column index to the prefix. | `Column-` |
| Allow reading rows with all column cells as empty | Whether to keep rows in which every cell is empty. Empty rows at the end of a sheet are always dropped. | False |
| Number of rows to check for nulls in all columns | Maximum number of consecutive empty rows to keep before Prophecy skips empty rows until the next row with data. Appears only when **Allow reading rows with all column cells as empty** is enabled. | `100` |
| Skip Undefined Rows | Whether to skip rows where all values are undefined. | False |
| Date Format Reference | Date format to use when parsing date values. | `2006-01-02` |
| Time Format Reference | Time format to use when parsing time values. | `15:04:05` |
| Timestamp Format Reference | Timestamp format to use when parsing date-time values. | `2006-01-02 15:04:05` |
| Inference Data Sampling Limit | Maximum number of rows to sample for inferring the schema. | `0` |
| Password | Password for password-protected sheets. | None |
| Source File Column Name | Name of the column that stores each row's source file name. Appears only when **Include filename Column** is enabled in the Source gem. After you change this value, click **Infer Schema** to update the output schema. | `FileName` |
| Last Modified Timestamp Column Name | Name of the column that stores each source file's last modified timestamp. Appears only when **Include file last modified timestamp Column** is enabled in an [SFTP](https://docs.prophecy.ai/data-analysis/gems/source-target/file/sftp.md) Source gem. After you change this value, click **Infer Schema** to update the output schema. | `FileModifiedDate` |
| Output Sheet Column Name | Name of the column that stores the sheet name for each row. Appears only when **Include sheet name Column** is enabled in the Source gem. | `sheet_name` |
| Append record id column to the output schema | Whether to add a record ID column to the output schema. | False |
| Record ID Column Name | Name of the record ID column. Appears only when **Append record id column to the output schema** is enabled. | `RecordId` |

### Reading sheets

Depending on the **Sheet Reading method** you choose, you will need to provide additional details.

#### Read single sheet data

For this option, Prophecy only reads one sheet of the Excel file.

| Additional property | Description |
| - | - |
| Sheet Name | Provide the name of the sheet to read. If the name you provide does not match the name of an existing sheet in the file, the gem will fail to run. |

#### Read union of multiple sheet data

For this option, Prophecy reads the data from each of the sheets that you specify. Then, the data is unioned into one output table.

| Additional property | Description |
| - | - |
| Sheet Filter Condition | Choose how you define the set of sheets to read. <ul><li>**Sheet name prefix equals**: Read sheets whose names start with the provided value.</li><li>**Sheet name suffix equals**: Read sheets whose names end with the provided value.</li><li>**Sheet name contains value**: Read sheets whose names contain the provided substring.</li><li>**Sheet name is in below list (comma separated)**: Read sheets whose names exactly match any comma-separated value provided in *Filter Value*.</li></ul> |
| Filter Value | Provide the value used to evaluate the filter condition. |

> [!NOTE]
>
> The union operation will only succeed if each sheet has the same schema.

## Target properties

The following properties are available for the Excel Target gem.

| Property | Description | Default |
| - | - | - |
| Skip if zero input rows | If enabled, the Target gem is skipped when its input has no rows, and no file is written. If disabled and **Header** is enabled, an empty input writes a file that contains only the header row. | False |
| Description | Description of the table. | None |
| Sheet Write method | Choose how rows are written. The options depend on the [Excel output mode](#excel-output-mode).  When creating a new file or a file from a template: <ul><li>**Write data to a single sheet**: All rows are written to one sheet specified in *Sheet Name*. The sheet is created if it does not exist.</li><li>**Dynamic data write to multiple sheet**: Rows are partitioned by the value in *Sheet Column Name*, and each partition is written to a sheet with that name. Sheets are created as needed.</li><li>**Dynamic data write to multiple files as per file column name**: Rows are grouped by the value in *File Column Name*, and each group is written to its own Excel file. See [Write to multiple files](#write-to-multiple-files).</li></ul>When updating an existing file: <ul><li>**Update a single sheet (keeps the other cells)**: Rows are written into the sheet specified in *Sheet Name*. Cells outside the written range keep their existing values.</li><li>**Replace a single sheet (clears it first)**: The sheet specified in *Sheet Name* is cleared, then the rows are written. The sheet keeps its position in the workbook.</li><li>**Dynamic data write to multiple sheet**: Same as above.</li></ul> | Write data to a single sheet |
| Sheet Name/Sheet Column Name | Configure the destination name reference. <ul><li>**Single sheet**: Provide the exact sheet name to write to (for example, `Sheet1`).</li><li>**Multiple sheets**: Provide the column that contains the target sheet name for each row. </li></ul> | `Sheet1` |
| File Column Name | Column whose values determine which file each row is written to. Must be a column in the input schema. Only appears when writing to multiple files. | None |
| Output File Sheet Name | Name of the sheet to write to in each file. Only appears when writing to multiple files. | `Sheet1` |
| File Prefix for multi file write | Text added to the start of each file name. Only appears when writing to multiple files. | None |
| Start Cell | Cell where writing begins, such as `C3`. If **Header** is enabled, the header is written at this cell and data starts on the next row. | `A1` |
| Header | Whether to make the first row the column header. | True |
| Use Schema | If enabled, cells are formatted by their schema data type (for example, dates as dates and numbers as numbers). If disabled, all values are written in the General format. | False |
| Ignore Cell Formatting | Whether to apply the number format for the cell value or get the raw value. | True |
| Custom Time Format | Display format for time columns, such as `HH:mm:ss` or `h:mm:ss AM/PM`. Applies when **Use Schema** is enabled. | None |
| Password | Password used to protect the output workbook. Leave empty to write an unprotected file. | None |

### Excel output mode

The **Excel Output Mode** setting appears in the **Location** tab of the Target gem when the format type is `xlsx`. It controls whether the gem creates a new workbook or writes into an existing one.

| Mode | Behavior |
| - | - |
| Create a new Excel file | Writes a new workbook to the **Target file path**. Any existing file at that path is replaced in full, including its other sheets. This is the default. |
| Create a new Excel file from a template | Builds a new workbook from the file in **Template file path** and writes it to the **Target file path**. The template's layout and other content are kept in the output, and the template file itself is not changed. Any existing file at the target path is replaced in full. |
| Update an existing Excel file | Opens the workbook at **Base file path** and writes only the selected sheet. All other sheets and their positions are kept. The sheet or the file is created if it does not exist. |

> [!NOTE]
>
> **Dynamic data write to multiple files as per file column name** is not available when updating an
> existing Excel file.

### Write to multiple files

When **Sheet Write method** is set to **Dynamic data write to multiple files as per file column name**, the gem writes one Excel file for each unique value in the **File Column Name** column. Each file is named `<prefix><value>.xlsx`, where `<prefix>` is the **File Prefix for multi file write** value. Rows are written to the sheet named in **Output File Sheet Name**.

Where the files are written depends on the file path configured in the gem:

* If the path ends with `/` or has no file extension, it is treated as a folder, and the files are written inside it. For example, with the prefix `File_`, the path `exports/orders/` produces `exports/orders/File_US.xlsx`, `exports/orders/File_EU.xlsx`, and so on.
* If the path includes a file name, such as `exports/orders.xlsx`, the files are written to that file's parent folder. The file name itself is ignored.

Rows with a null or blank value in the file column are written to `<prefix>unknown.xlsx`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.