# ExportData

ExportData automatically exports data in a spreadsheet cell to a Cell Data (.CXD) file according to a predetermined event in the spreadsheet. It allows you to export the data within a single cell on a vision system to one of the following locations:

- Flash memory of a local device
- FTP server
- SFTP server

Note: The ExportData function cannot export .CXD files to the Snippets folder on the PC.

When you export a .CXD file using the ExportData function, the data becomes a part of the ExportData function and cannot be edited. When you click on an exported .CXD file, the ExportData property sheet opens up, not the property sheet for the type of data that was exported. You can export the following data types:

- DelayLine: For more information, see DelayLine.
- CountPassFail: For more information, see CountPassFail.
- Calibrate: For more information, see Calibrate.
- OCRMax: For more information, see OCRMax.
- OCRMaxSettings: For more information, see OCRMaxSettings.
- TrainPatMaxPattern: For more information, see TrainPatMaxPattern.

CAUTION:

- Writing data from the ExportData function is a potential job blocking function. Jobs can be slowed down and a vision system may queue or miss a trigger if the job takes longer to process than the trigger period.

## ExportDataInputs

Syntax: ExportData(Event,Host Name,User Name,Password,File Name,Data to Export)

Parameter | Description
--- | ---
Event | Specifies the update event on which to read data. This parameter must be a reference to one of the following: The Image data structure in cell A0, containing the AcquireImage function. For more information, see AcquireImage. Note: If you write the data to a flash memory and the Event is set to the Image data structure, the function returns an #ERR. A cell containing an Event function. For more information, see Event. A cell containing a Button function. For more information, see Button. Note: The default Event parameter setting for the ExportData function is 0, and if the setting remains 0, an ExportData button will be created next to the ExportData cell.
Storage | Specifies where the data is stored. There are three options: Local Device FTP Server SFTP Server
Host Name | Name/IP address of the server where you save the file. Only available when you select FTP/SFTP server as Storage. Note: If the server is unavailable at the time of the data transfer, it will take several seconds to timeout. In-Sight may disconnect from the vision system if this occurs.
User Name | Specifies the user name that accesses the server. Only available when you select FTP/SFTP server as Storage.
Password | Specifies the password that accesses the server. Only available when you select FTP/SFTP server as Storage.
File Path | Specifies the data file path. If left blank, ExportData uses the default device directory. ExportData supports all valid absolute or relative PC paths.
File Name | Specifies a custom name for the file. If the file name already exists on the target location, the existing file will be overwritten. Note: Do not enter a file extension, it is automatically added to the string.
Data to Export | Cell reference to a data structure to export. If a cell contains a reference to another structure, such as a GetString reference, the tool exports the actual value contained in the cell.

## ExportDataOutputs

Returns | Creates a .CXD file that can be stored on an local device, or FTP/SFTP Server. Note: If ExportData returns an #ERR as a result, you can utilize GetErrorString to determine the cause.

ExportData exports the .CXD file when one of the following occurs:

- You press the OK button on the ExportData property sheet.

- The tool receives an Event.

- The Event parameter is ON (or points to a non-zero numeric value), and one of the ExportData input parameters is updated.

  Note: ExportData works in Offline mode as well.

## ExportData Example

ExportData(A8,"FTPServer1","operator1","","PartXPattern",H7)

Whenever the spreadsheet updates after an event is triggered in cell A8, the function writes the data in cell H7, as a file named PartXPattern.cxd, to the server named FTPServer1. The user name is specified as operator1, and the password is left blank.