打开导航
从数据库检索数据时,BarTender 可能会发现不包含任何数据的字段。 在此类情况下,您可能希望不打印数据源,这样您的打印项中将不会显示空白区。 请考虑以下示例:
A retail company prints shipping labels, and the "Ship To" address that is printed on the labels is retrieved from a central customer database. 某些记录包含客户名称和公司,而其他记录仅包含客户名称或公司名称,如下面的示例数据所示:
"CustomerName","CompanyName","Address","City","State","ZIP"
"Jake Diamond","Diamond, Inc.","PO Box 60","Gem Town","NV","50897"
"Meg Reilly","","148 Circle Drive","Maple","WA","98005"
"","All-State Trucking","5601 Interstate","Huntsville","IN","40890"
请注意,空字段会以双引号 "" 指出。
如果保存为文本文件,那么可以将以上每条信息用作数据库字段,这样就可以创建可动态地从数据库拉出信息的地址模板。
如果您将模板设置为将每个字段打印为单独的文本对象,那么标签可能会打印如下:
Jake Diamond Diamond, Inc. PO Box 60 Gem Town, NV 50897
|
Meg Reilly 148 Circle Drive Maple, WA 98005
|
All-State Trucking 5601 Interstate Huntsville, IN 40890
|
请注意,第二笔记录中的第二个字段为空白,第三笔记录中的第一个字段为空白。 You can avoid these skipped lines by specifying that BarTender suppress a carriage return whenever the previous data source is empty.
使用此方法,三个相同标签将打印如下(没有跳行):
Jake Diamond Diamond, Inc. PO Box 60 Gem Town, NV 50897
|
Meg Reilly 148 Circle Drive Maple, WA 98005
|
All-State Trucking 5601 Interstate Huntsville, IN 40890
|
To set up a BarTender document for this scenario, follow these steps:
-
创建数据库。
-
打开 BarTender 并创建新空白文档。
-
连接至数据库。
-
创建地址标签文本对象。
-
配置地址标签文本对象。
-
不打印空白字段。
请参见下面详细的步骤:
创建数据库
-
将上面的示例数据库复制到文本文件。
-
以回车分隔每一行。
-
将文件保存为 SuppressionExample.txt。
连接至数据库
-
从 BarTender“文件”菜单中选择“数据库设置”以打开“数据库设置向导”。
-
在“数据库设置向导”中,选择“文本文件”。
-
单击“下一步”。
-
单击“选择文件”。
-
导航到 SuppressionExample.txt 并单击“打开”。
-
单击“下一步”。
-
从“字段分隔”下拉列表中,选择“引号和逗号”。
-
单击“下一步”。
-
选择“第一行是包含字段名的标题”。
-
单击完成。
-
单击确定。
创建文本对象
-
从对象工具栏中选择
以添加文本对象。 或者,从“创建”菜单中选择“文本”。
-
从可用文本类型列表中,选择“多行”。 默认情况下,多行文本对话在“文本格式属性”页面会定义为段落。
-
单击模板以放置文本对象。
配置地址
-
双击文本对象以打开“文本属性”对话框。 Alternatively, right-click the object to select Properties from the object's context menu.
-
从“导航窗格”中选择所需的数据源。
-
在“导航窗格”的底部,单击
,以打开“新建数据源向导”。
-
对于“类型”,从下拉列表中选择“数据库字段”并单击“下一步”。
-
对于“字段”,选择所需的数据库字段。 (CustomerName 应该是本示例中的第一个字段)。
-
在“样本数据”字段中,输入一些描述数据库字段的文本。 例如,对于字段 CustomerName,您可以输入“客户名称”或通用示例,如“Jane Doe”。
-
单击“结束”以关闭该向导。
-
单击
以打开“新建数据源向导”。
-
Select Embedded Data as the data source type.
-
单击“结束”以关闭该向导。
-
在“导航窗格”中,选择您刚创建的数据源。
-
In the Embedded Data field, highlight the sample text, and then press Enter to insert a carriage return.
-
对于每行地址,重复步骤 3-7:
-
"CompanyName"
-
"StreetAddress"
-
"City"
-
"State"
-
"ZIP"
-
在左侧的“导航窗格”中,选择带有回车的嵌入数据源,并单击窗格底部的
,以复制该数据源。 Alternatively, right-click to select Copy from the selected data source's context menu.
-
选择 CustomerName 数据库字段并单击
,以将回车粘贴在字段后面。 Alternatively, right-click to select Paste from the database field's context menu.
-
Paste a carriage return after CompanyName and StreetAddress.
-
在 City 后,插入由单个逗号后接一个空格组成的嵌入数据源。
-
在 State 后,插入仅由一个空格组成的嵌入数据源。
-
完成时,关闭“属性”对话框。
从“文件”菜单中选择“打印预览”。 当您浏览整页记录时,您会发现在第二和第三笔记录中遗漏了行。
不打印空白字段
-
双击文本对象以打开“文本属性”对话框。 Alternatively, right-click the object to select Properties from the object's context menu.
-
In the left Navigation Pane, select the first embedded data source that contains a carriage return.
-
选择“转换”选项卡。
-
单击“抑制”右侧的
,以打开“抑制”对话框。
-
选择”当前一个数据源为空时抑制”。
-
单击“确定”以关闭“抑制”对话框。
-
针对每个包含回车的嵌入数据源重复以上步骤。
-
单击“关闭”以关闭“文本属性”对话框。
从“文件”菜单中选择“打印预览”。 当您浏览整页记录时,第二和第三笔记录中的空白行不见了。
相关主题