Table objects to help you organize the placement of objects within a template while designing your label. They also offer the possibility for the table to be connected to a database directly. This article will provide instructions on how to leverage this functionality to populate a single label with data from multiple records in a database.
BarTender 2019 and above
The grid of a table object resizes automatically at print time based on the size of the objects contained in its cells. In addition, when you create a table object that is connected to a database, the number of rows and columns adjusts automatically to the number of records to be displayed when the document is printed.
Create a Sample Database File
The sample database that will be used in this example to connect it to the table object of the template is a comma-delimited CSV file. It contains ten records of data, and its structure consists of the following columns: Title, FirstName, LastName, CompanyName, Phone, AddressLine1, City, StateProvince, CountryRegion and PostalCode.
Ms.,Virginia,Miller,All Cycle Shop,918-555-0127,8713 Yosemite Ct.,Bothell,Washington,United States,98011
Mr.,John,Beaver,Center Cycle Shop,521-555-0195,1318 Lasalle Street,Bothell,Washington,United States,98011
Mr.,Paulo,Lisboa,Elite Bikes,380-555-0116,9178 Jumping St.,Dallas,Texas,United States,75201
Create the BarTender Document
Prepare the label and create the Table Object for our Database by associating the database connection to the CSV file.
- Open TestLabel.btw.
- Create a Table Object by clicking on the Table icon in the Toolbar (or alternately from the Create menu, select Table), and then select Create Table from Database.
- Complete the Database Connection wizard to connect to your database (TESTDB.csv). For more information about the types of databases that you can connect to, refer to Supported Database Types.
- Use the Database Setup Dialog to configure additional properties to define the record set that you want from the database(for example, via an SQL query: Using the Table Object with Advanced SQL Queries), and then click OK to close the dialog.
- Configure the Table Object properties by double-clicking it, or right-clicking and selecting Properties.
- In this example, we have configured our first Row as Page Header, which will show the associated database field names.
- Configure the Row and Column properties depending on your needs. It's possible to insert, delete, duplicate, move a row or a column up or down, set height and alignment, as well as other options.
- You can also configure the Borders and Shading options as per your needs. Find further information about each of the settings in the BarTender Help System, also available online.
- Optionally add other objects to the label as per your needs.
- Save the label.
- When you Preview or Print the label, you will see that the database records are printed in a table format within a single label.
Adding Table Data Field Data Sources to the Table
After you select the source that you want for the table data, the Table Data Fields data source type is added to the Data Sources pane of the Toolbox. Expand the Table Data Fields node in the Data Sources pane to view the available data sources that are related to the source that you selected for your table data.
Add a Table Data Field data source to the table by dragging it from the Toolbox. This method creates a text object.