JobDataCsv

Native C API

Overview

CSV files and other text files in a suitable format provide records for generating output. Use TFormer_SetTxtDataFile to import the file into the current TFORMer instance.

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 SDK matches the column names in the file with the corresponding DataField names in the FormLayout. Therefore the first row of the file must contain the DataField names, separated by a separator character. All other rows contain the DataField values, again separated by a separator character. Each value or name of a DataField may be enclosed in optional qualifier characters. This is useful if the separator character may be part of a DataField value.

Pass the separator and qualifier explicitly to TFormer_SetTxtDataFile. For comma-separated values enclosed in double quotes, pass a comma (,) and a double quote ("). Pass zero as the qualifier if the file uses no qualifiers.

Example

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:

"Email","JobTitle","Name"
"support@tec-it.com","Support Engineer","Mr. Harald Backoffice"
"sales@tec-it.com","Sales Assistant","Mrs. Susan Frontdesk"

Save the CSV data above as a file and update the input path in the example to match its location. The example imports this file and generates PDF output.

  // Use an initialized TFORMer instance

  // Select the FormLayout (stand-alone or Repository-based)
  // ...

  // Here we import a CSV and specify separator and qualifier character
  eCode = TFormer_SetTxtDataFile    (hTForm, "c:/temp/Import.txt", ',', '\"');

  // Select PDF output
  if (eCode == ErrOk)
    eCode = TFormer_SetPrinterType  (hTForm, ePrinterType_PDFFile);

  // To /temp/out.pdf
  if (eCode == ErrOk)
    eCode = TFormer_SetOutputName   (hTForm, "/temp/out.pdf");

  // Generate output based on the FormLayout and the JobData
  if (eCode == ErrOk)
    eCode = TFormer_Print           (hTForm);

More Information

For a general description see JobData.

Search documentation

Search in
More scopes
Additional scopes

All contents