JobDataCsv class
Package: com.tecit.TFORMer.Printing
Provides access to JobDataCsv (a CSV-file that serves as JobData for a Job).
Usage and notes
Overview
CSV files and other text files in a suitable format provide records for generating output. Use JobDataCsv to supply the file as the JobData of 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 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.
The default separator is a comma (,) and the default qualifier is a double quote ("). Set the qualifier to the null character ('\0') 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.
// Create a new Job instance
Job printJob = new Job();
// Select the FormLayout (stand-alone or Repository-based)
// ...
// Create a new JobData instance
// Here we import a CSV and specify separator and qualifier character
JobDataCsv jobData = new JobDataCsv("c:/temp/Import.txt", ',', '"');
// Assign the JobData to the Job
printJob.setJobData(jobData);
// Select PDF output to /temp/out.pdf
printJob.setOutputName ("/temp/out.pdf");
printJob.setPrinterType (EPrinterType.PDFFile);
// Generate output based on the FormLayout and the JobData
printJob.print ();
More Information
For a general description see JobData.
See also
Note
Thread-safety: A single instance of this class must not be used by different threads.
Inheritance and related types
Base types: JobData
Inherited members (4)
Constructors
| Member | Description |
|---|---|
| JobDataCsv() | Constructor for JobDataCsv. |
| JobDataCsv(String, char, char) | Constructor for JobDataCsv. |
Methods
| Member | Description |
|---|---|
| getFilename() | Gets the filename of the CSV file. |
| getQualifier() | Gets the qualifier character that encloses DataField values. |
| getRecordCopyDataField() | Gets the name of the DataField which specifies the number of Record copies. |
| getSeparator() | |
| setFilename(String) | Sets the filename of the CSV file. |
| setQualifier(char) | Sets the qualifier character that encloses DataField values. |
| setRecordCopyDataField(String) | Sets the name of the DataField which specifies the number of record copies. |
| setSeparator(char) |