ERRCODE TFormer_SetTxtDataFile ( HTFORM  pInstance,
LPCSTR  pszFileName,
CHAR  cSeparator,
CHAR  cTextQualifier 
)

Specifies a text-file as DataSource.

Returns:
- ErrOk (0) in case of success
- Non-zero if error occurred
Parameters:
[in] pInstance The TFORMer-Instance provided by a previous call to TFormer_Init.
[in] pszFileName Data-File Name.
[in] cSeparator DataField separator (e.g. , or ;).
[in] cTextQualifier Text qualifier (e.g. ' or " - default is none).
Remarks:
This DataSource enables TFORMer Runtime to use CSV-files (or more generic: any text file in a suitable format) as a DataSource for printing a Job.
The data in such a file provides the values of the DataFields. Each line (except the first one - see below) is treated as a Record. TFORMer Runtime must match the values in the file with the corresponding DataField-names. Therefore the first row of the file must contain the DataField-names (see TFormer_SetVarValue), separated by a Separator-character. All other rows contain the DataField-values, again separated by a Separator.
Each value or name of a DataField may be enclosed in optional Qualifier-characters. This is useful if the Separator-character may be a part of a value.
Note:
Behavior if no input data was supplied: If no DataSource was specified (either by TFormer_SetXXXDataFile, TFormer_SetODBCData or via TFormer_NewRecord and TFormer_SetVarValue) the default data-file (located in the same directory as the FormLayout itself and generated by the last TFORMer Designer session) is used. If this default data-file does not exists no output will be produced. The name of the default data-file is path/FormName.xml.

A data file may be passed in the following ways:

  • Specify the filename directly.
  • Specify the filename of a ZIP-file (e.g. with WinZip) containing the required file.
  • BASE64-encode the content of the required file (see Convert class of .NET) and use this string instead of a filename.
  • BASE64-encode the content of a ZIP-file (see Convert class of .NET) containing the required file(s). Use this string instead of a filename.

Note:
BASE64 encoded strings must start with the sequence BASE64:. When passing a zipped file TFORMer expects a real WinZip compatible format. A zipped stream is not suitable! For more details please refer to the TFORMer Runtime DLL Programming Reference.

Must be called after TFormer_SetFormName and before TFormer_Print.

The following example file contains 2 records. The first line lists the DataField-names. The comma (,) is used as Separator-character and the double quote (") is used as Qualifier-character:
Sample CSV-File
Name/Value SeparatorName/Value SeparatorName/Value
"Email" , "JobTitle" , "Name"
"support@tec-it.com", "Support Engineer" , "Mr. Harald Backoffice"
"sales@tec-it.com" , "Sales Assistant" , "Mrs. Susan Frontdesk"

See also:
TFormer_SetXmlDataFile, TFormer_SetImportFieldForRecordCopy.


© 2006-2009 - all rights reserved by TEC-IT Datenverarbeitung GmbH
Generated on Wed Sep 2 16:01:09 2009 for TFORMer Runtime DLL/Shared Library with doxygen 1.5.8