本教程主要介绍如何利用 IDAutomation的线性Java条码包和以逗号分隔的文件作为数据源来创建一个带有页面布局的报表。
Step 1:利用逗号分隔的数据源创建报表
下载并保存文本文件,ProductInv.txt和InventoryPDS.txt。
在文本编辑器中打开InventoryPDS.txt。
查看是否关闭报表生成器。
启动另外一个文本编辑器会话,然后打开textpds.conf。该文件位于Oracle_Home/reports/conf directory。该文件可启用报表生成器来识别ProductInv.txt作为数据源插件。
将InventoryPDS.txt中的文本拷贝至textpds.conf。复制之前的所有数据。
保存并关闭这两个文本文件。
启动报表生成器。
选择并确定"Use Report Wizard"。
如果显示"Welcome to the Report Wizard"欢迎界面,请点击OK。
选择"Create Paper Layout Only", 单击Next。
将报表命名为 "Product Inventory",选择"Group Above",然后点击Next。
在Data Source步骤中,选择"Text Query",然后选择Next。
Query Definition按钮。
在下拉列表中找到ProdInvCSV。
点击数据源下的Browse按钮。
在报表向导的"Data Source Definition"页面点击Next。
选择Category后点击右箭头(>),然后点击Next,可将Category移至"Group Fields"列表。
点击双右箭头(>>),将所有字段移动到显示字段的列表,点击Next。
点击向导中Totals page上的Next按钮。
点击向导中Labels page上的Next按钮。
为报表的预定义模板选择颜色,然后单击Next。
点击Finish。
将报表另存为Inventory.jsp。
Step 2:添加 Linear Barcode .jar file至Oracle Reports
/******************************************************************/
/*name of temp file*/
ImageFile VarChar2(250);
/*object containing barcode properties*/
BarcodeObject ORA_JAVA.JOBJECT;
/*object that creates jpeg of barcode based on BarcodeObject*/
BarcodeEncoderObject ORA_JAVA.JOBJECT;
begin
/*Get a temporary file name for the jpeg*/
/*On Solaris Unix, use the following code to create the temp file: ImageFile := srw.create_temporary_filename() || '.jpg'; */
imageFile := srw.create_temporary_filename();
/*Create the barcode object*/
BarcodeObject := BarCode.new();
/*Set the symbology*/
BarCode.setSymbologyID(BarcodeObject, BarCode.CODE128);
/*set the data to encode*/
BarCode.setDataToEncode(BarcodeObject, to_char(:ProductID));
/*Create the jpeg*/
BarcodeEncoderObject := BarcodeEncoder.new(BarcodeObject, 'JPEG',ImageFile);
/*If, for some reason, the barcode is not created, return null
otherwise, return the name of the barcode image jpeg that was
created */
if ORA_JAVA.IS_NULL(BarcodeEncoderObject) then
return(NULL);
else
return(ImageFile);
end if;
/******************************************************************/
查看Oracle报表是否未必运行。
将LinearBarcode.jar保存至一个易于记忆的位置。
更新REPORTS_CLASSPATH环境变量,使其包含JAR文件。
打开Oracle Reports。
选择"Open an Existing Report",然后点击OK。
选择Inventory.rdf,点击Open。
在程序菜单项中,点击Import Java Classes。
浏览COM | IDAutomation | Linear | Barcode,然后点击Import。
浏览COM | IDAutomation | Linear | Encoder | barCodeEncoder,然后点击Import。
在对象浏览器中,双击数据模板旁边的图标,打开数据模型编辑器。
点击工具栏中的Formula Column对象。
在数据模型查看器的G_Product面板中绘制Formula Column对象。
双击新的Formula Column字段以弹出属性检查器窗口。
将数据类型属性改为Character。
点击属性检查器中PL/SQL Formula属性旁边的公式框,打开PL/SQL编辑器。
利用下列代码替换掉函数定义和'end;'之间的代码:
编辑PL/ SQL编辑器中的代码以确保没有错误并关闭PL / SQL窗口。
双击Object Navigator中Paper Layout旁边的图标以打开Page Layout。
确定已选择Paper Layout中的table,将工具栏中的字段对象拖动至窗体。
双击Formula Field, F_1以调出属性检查器。
保存报表。
在程序菜单中选择Compile | All选项。
从报表生成器菜单中选择Program | Run Paper Layout。
根据需要可以在Report Layout Editor中调整报表布局,格式和字段大小。
标签:条形码条码生成条码读取条码字体
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,尊重他人劳动成果