Skip to main content

Range to Text

The Range to Text function exports a range of cells to a text file in the file format specified.

Settings

Format

The file format for the text file can be CSV (Comma Delimited) or Text (Tab Delimited) format.

Directory

The directory where the text file is stored. If this is left blank, the text file is stored in the Reports Directory of the current project (as defined in the Project Explorer). If this is not a full path reference, the setting is used as subfolders of the Reports Directory. If any part of the directory does not exist, it is created.

This can be a fixed name or cell reference where the cell reference contains the directory. Fixed names can contain XLReporter Name Types like {YYYY}, {MMM}, etc. See the Name Types chapter for the full list of supported keywords. Note that some keywords, such as {DATIM} contain illegal directory characters when evaluated. These keywords cannot be used for the directory.

File

The name of the text file to export the range to with or without a file extension. If the file extension is not specified, it is derived from the Format setting (either CSV or TXT).

If this setting is left blank, the text file is named after the target workbook in the format Workbookt.FileExtension where FileExtension is either CSV or TXT depending on the Format setting. If this is run on demand the target workbook is the name of the template.

Keywords for the date and time can be entered for the file name e.g., entering {MMM}_{DD}_{YYYY}.csv will name a report generated on June 1st 2020 as Jun_1_2020.csv. Note that some keywords, such as {DATIM} contain illegal file name characters when evaluated. These keywords cannot be used for the file name.

This setting may also be specified as a cell reference.

Overwrite

If set to Yes, the text file is overwritten if it exists. If set to No and the file exists, nothing is done.

Example

A report template is designed to show 15-minute samples as well as daily summaries and a chart of the samples throughout the day. Those 15-minute samples need to be exported to a csv file so that can be imported into a data analysis system which keeps track of the entire facility.

To export the 15-minute samples a Range to Text function is used. If the data range starts at $B$8:$H$8, the settings are:

Apply To

Cell

$B$8:$H$8

Direction

Down

End

All cells are empty

Setting

Value

Format

CSV (Comma Delimited)

Directory

\\FileServer\Analysis

File

{YYYY}-{MM}-{DD}.csv

Overwrite

No

Where FileServer is the name or IP address of the target location.