Repor&ng ¡Solu&ons ¡for ¡Oracle ¡APEX ¡-‑ ¡ Choose ¡Your ¡Weapons ¡
Dietmar ¡Aust ¡ Opal-‑Consul&ng, ¡Köln ¡ www.opal-‑consul&ng.de ¡
Repor&ng Solu&ons for Oracle APEX - Choose Your - - PowerPoint PPT Presentation
Repor&ng Solu&ons for Oracle APEX - Choose Your Weapons Dietmar Aust Opal-Consul&ng, Kln www.opal-consul&ng.de Vorstellung Opal Consul&ng
Dietmar ¡Aust ¡ Opal-‑Consul&ng, ¡Köln ¡ www.opal-‑consul&ng.de ¡
► Building ¡Oracle ¡based ¡Web ¡Applica&ons ¡since ¡1997 ¡
▪ Portal, ¡Forms, ¡Reports, ¡OWA ¡Toolkit, ¡now ¡APEX! ¡
► Dipl.-‑Inform. ¡Dietmar ¡Aust, ¡Freelance ¡Consultant ¡
▪ Master's ¡Degree ¡in ¡Computer ¡Science ¡(MSCS) ¡
► 1997-‑2000: ¡Consultant ¡at ¡Oracle ¡Germany ¡ ► Since ¡09/2000: ¡Freelance ¡Consultant, ¡Since ¡2006 ¡– ¡APEX ¡
► Blog: ¡h[p://daust.blogspot.com/ ¡ ► Regular ¡presenter ¡at ¡Oracle ¡conferences ¡(ODTUG, ¡DOAG, ¡ OOW) ¡ ► Author ¡of ¡the ¡JasperReportsIntegra&on ¡toolkit ¡
▪ h[p://www.opal-‑consul&ng.de/tools ¡
¡
Vorstellung ¡Opal ¡Consul&ng ¡ ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 2
25.03.2014 Reporting Solutions for Oracle APEX Page 3
Major ¡Use ¡Cases ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 4
► What ¡is ¡it ¡/ ¡Examples? ¡
▪ Crea&ng ¡Invoices, ¡Order ¡Confirma&ons, ¡Contracts ¡ ▪ Management ¡reports ¡/ ¡dashboards ¡/ ¡charts ¡
► Characteris&cs ¡
▪ Client-‑independence, ¡can ¡possibly ¡be ¡downloaded ¡from ¡your ¡website ¡ ▪ Not ¡easily ¡modifyable ¡ ▪ Need ¡pixel ¡perfect ¡layout ¡/ ¡corporate ¡design ¡ ▪ Fixed ¡layout, ¡infrequent ¡changes ¡ ▪ Generate ¡as ¡BLOB, ¡can ¡be ¡stored ¡in ¡the ¡database ¡together ¡with ¡the ¡ client ¡/ ¡order ¡entry, ¡etc. ¡
Major ¡Use ¡Cases ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 5
► What ¡is ¡it ¡/ ¡Examples ¡ ¡-‑ ¡two ¡situa&ons: ¡
customer ¡communica&on), ¡E.g. ¡flexible ¡offer ¡crea&on ¡where ¡you ¡need ¡to ¡ add ¡calcula&ons ¡from ¡MS ¡Excel ¡or ¡add ¡images, ¡etc. ¡
► Characteris&cs ¡
▪ Needs ¡to ¡be ¡modifyable ¡aier ¡the ¡genera&on ¡ ▪ Corporate ¡design ¡s&ll ¡important ¡ ▪ Possibly ¡frequent ¡changes ¡in ¡the ¡template ¡
Major ¡Use ¡Cases ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 6
► What ¡is ¡it ¡/ ¡Examples? ¡
▪ The ¡users ¡want ¡to ¡export ¡the ¡data ¡to ¡further ¡process ¡it ¡
► Characteris&cs ¡
▪ Proper ¡data ¡types ¡– ¡CSV ¡format ¡problema&c ¡ ▪ Perhaps ¡formajng ¡ ▪ Export ¡mul&ple ¡worksheets ¡at ¡the ¡same ¡&me ¡ ▪ Using ¡na&ve ¡features ¡like ¡autofilter, ¡macros, ¡condi&onal ¡formajng ¡ ▪ Show ¡/ ¡hide ¡columns ¡ ▪ Charts, ¡Pivot-‑tables, ¡password ¡protec&on ¡for ¡files ¡and ¡worksheets ¡
Major ¡Use ¡Cases ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 7
Major ¡Use ¡Cases ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 8
25.03.2014 Reporting Solutions for Oracle APEX Page 9
► APEX ¡out-‑of-‑the-‑box ¡support ¡: ¡ ¡ ► Interac&ve ¡Reports: ¡ ► Classic ¡Reports: ¡ ¡
▪ CSV ¡ ▪ XML ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 10
► XSL ¡-‑ ¡Formajng ¡Objects ¡
▪ Markup ¡Language ¡for ¡XML ¡documents ¡ ▪ Requires ¡an ¡XSL-‑FO ¡Processor ¡to ¡generate ¡the ¡final ¡doc ¡
► Oracle ¡APEX ¡uses ¡Apache ¡FOP ¡(1.0), ¡ships ¡the ¡file ¡fop.war ¡to ¡be ¡deployed ¡in ¡ an ¡OC4J ¡J2EE ¡server. ¡ ► ¡Basically ¡what ¡we ¡need ¡at ¡run&me ¡are ¡two ¡xml ¡files: ¡ ¡
▪ The ¡data ¡ ¡ ▪ The ¡layout ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 11
► The ¡Architecture ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 12
► Setup ¡in ¡the ¡Internal ¡Administra&on: ¡ ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 13
► Interac&ve ¡Reports: ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 14
► The ¡basic ¡integra&on ¡uses ¡ Generic ¡Columns ¡ ► Each ¡column ¡is ¡forma[ed ¡in ¡the ¡ same ¡way ¡ ► Basic ¡formajng ¡in ¡the ¡print ¡ sec&on ¡for ¡classic ¡reports: ¡ ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 15
► You ¡can ¡also ¡use ¡Named ¡Columns ¡Templates ¡ ► Step ¡1: ¡get ¡the ¡XML ¡either ¡from ¡an ¡exis&ng ¡report ¡or ¡from ¡a ¡defined ¡report ¡ query ¡ ► Step ¡2: ¡Design ¡the ¡layout ¡based ¡on ¡the ¡sample ¡XML ¡file ¡ ► Step ¡3: ¡Upload ¡the ¡XSL-‑FO ¡file ¡to ¡Shared ¡Components ¡> ¡Reports ¡> ¡Report ¡ Layouts ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 16
► Demo: ¡Classic ¡report ¡with ¡named ¡columns ¡layout ¡
► Demo: ¡Using ¡report ¡query ¡and ¡layout ¡together ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 17
► Using ¡the ¡API ¡APEX_UTIL.GET_PRINT_DOCUMENT ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 18
► 4 ¡different ¡func&on ¡ signatures ¡available ¡ ► Generates ¡BLOB ¡ ► Need ¡to ¡generate ¡the ¡ report ¡data ¡yourself ¡for ¡ use ¡with ¡dbms_scheduler, ¡ no ¡APEX ¡context ¡here ¡
► Complete ¡step-‑by-‑step ¡example ¡from ¡Marc ¡Sewtz: ¡ h[p://marcsewtz.blogspot.de/2013/04/pdf-‑prin&ng-‑with-‑oracle-‑ applica&on.html ¡ ► XSL-‑FO ¡WYSIWYG ¡Design ¡Tools ¡ ► ALTOVA ¡StyleVision ¡Enterprise ¡($629) ¡ ¡
▪ MS-‑Windows ¡Only ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 19
► ALTOVA ¡StyleVision ¡Enterprise ¡($629) ¡ ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 20
► ALTOVA ¡StyleVision ¡Enterprise ¡($629) ¡ ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 21
► StylusStudio ¡($695) ¡
▪ MS-‑Windows ¡Only ¡
► Java4Less ¡FO-‑Designer ¡($124.60) ¡ ¡
▪ h[p://www.java4less.com/fopdesigner/fodesigner.php ¡ ▪ Cross ¡Plarorm ¡(MAC, ¡Linux, ¡Windows, ¡...) ¡ ▪ Special ¡focus ¡on ¡Oracle ¡APEX, ¡step ¡by ¡step ¡instruc&ons ¡ ▪ Gets ¡you ¡up ¡and ¡running ¡quickly ¡ ▪ Windows ¡installer ¡for ¡their ¡own ¡J4L ¡FOP ¡print ¡server ¡(op&onal) ¡, ¡uses ¡Je[y ¡J2EE ¡ Server ¡and ¡works ¡immediately ¡ ▪ Cheap ¡in ¡comparison ¡ ▪ Designer ¡somewhat ¡limited ¡but ¡works ¡in ¡real ¡world ¡projects ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 22
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 23
► APEX ¡LISTENER ¡2.0+ ¡& ¡APEX ¡4.2.2+ ¡
▪ Includes ¡FOP ¡support ¡ ▪ No ¡extra ¡J2EE ¡container ¡necessary ¡
► Needs ¡to ¡be ¡configured ¡in ¡internal ¡administra&on ¡ ► Does ¡not ¡work ¡with ¡APEX_UTIL.GET_PRINT_DOCUMENT ¡API ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 24
► Architecture ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 25
► Oracle ¡BI ¡Publisher ¡ ► Powerful, ¡complete ¡repor&ng ¡solu&on ¡ ► Step ¡1: ¡get ¡the ¡XML ¡either ¡from ¡an ¡exis&ng ¡report ¡or ¡from ¡a ¡defined ¡report ¡ query ¡ ► Step ¡2: ¡Design ¡the ¡layout ¡based ¡on ¡the ¡sample ¡XML ¡file ¡using ¡MS ¡Word ¡and ¡ the ¡BI ¡Publisher ¡Plugin ¡ ► Step ¡3: ¡Upload ¡the ¡RTF ¡template ¡to ¡Shared ¡Components ¡> ¡Reports ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 26
► Addi&onal ¡formats: ¡MS ¡Word, ¡MS ¡Excel ¡ ► Handles ¡all ¡the ¡use ¡cases ¡pre[y ¡well ¡ ► You ¡can ¡leverage ¡exis&ng ¡templates ¡in ¡MS ¡Word ¡but ¡also ¡easily ¡produce ¡other ¡
► Too ¡expensive ¡for ¡most ¡projects ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 27
► PL/PDF ¡(h[p://www.plpdf.com/) ¡ ► Provides ¡a ¡set ¡of ¡PL/SQL ¡based ¡APIs ¡to ¡generate ¡PDF ¡files ¡from ¡the ¡Oracle ¡ database ¡ ► License ¡cost: ¡600$ ¡per ¡Oracle ¡instance ¡ ► A ¡simple ¡example: ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 28
► No ¡GUI ¡for ¡designing ¡the ¡report, ¡everything ¡needs ¡to ¡be ¡coded ¡ ► Interes&ng ¡features ¡for ¡manipula&ng ¡PDFs ¡
▪ PDF ¡Encrpy4on/Decryp4on ¡(40/128 ¡bit ¡RC4, ¡AES ¡and ¡Public ¡Key) ¡ ▪ PDF ¡Metadata ¡manipula&on ¡ ▪ Extrac&on ¡of ¡text ¡from ¡PDF ¡ ▪ Merging ¡PDF ¡documents ¡(2, ¡10 ¡or ¡unlimited) ¡ ▪ Replacement ¡of ¡URLs ¡in ¡a ¡PDF ¡document ¡ ▪ Stamp ¡content ¡or ¡watermark ¡into ¡a ¡PDF ¡document ¡(JPG/Text) ¡ ▪ Export ¡and ¡Import ¡PDF ¡form ¡data ¡(FDF ¡and ¡XFDF) ¡ ▪ Extract ¡pages ¡to ¡a ¡new ¡PDF ¡ ▪ Get ¡number ¡of ¡pages ¡ ▪ Compress ¡JPG ¡images ¡in ¡PDF ¡ ▪ add ¡Digital ¡Signature ¡to ¡PDF ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 29
► JasperReports ¡h[p://sourceforge.net/projects/jasperreports/ ¡ ¡ ► What ¡is ¡it? ¡
▪ Java ¡library ¡(jar ¡file), ¡can ¡be ¡be ¡embedded ¡into ¡any ¡java ¡applica&on ¡(e.g. ¡SWING, ¡ RCP, ¡J2EE, ¡on ¡the ¡command ¡line ¡using ¡ANT ¡or ¡just ¡a ¡plain ¡Java ¡Run&me) ¡ ▪ It ¡ships ¡with ¡other ¡Open ¡Source ¡libraries ¡like ¡iText, ¡Groovy, ¡Hibernate, ¡ JFreeChart, ¡Log4J, ¡POI, ¡etc. ¡ ▪ Community ¡and ¡professional ¡edi&ons ¡
► License: ¡GNU ¡Lesser ¡General ¡Public ¡License ¡version ¡3 ¡(LGPLv3) ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 30
► Features: ¡ ¡
▪ JasperReports ¡provides ¡a ¡comprehensive ¡feature ¡set ¡ ▪ Data ¡sources: ¡JDBC, ¡XML, ¡OLAP, ¡TEXT, ¡Hadoop ¡…, ¡and ¡extensibility ¡through ¡ ¡ custom ¡data ¡sources, ¡mul&ple ¡data ¡sources ¡per ¡report ¡ ▪ Output ¡formats: ¡pdf, ¡xls, ¡xlsx, ¡html, ¡xhmtl, ¡csv, ¡text, ¡rr, ¡odf, ¡docx, ¡pptx, ¡.. ¡ ▪ Matrix ¡reports ¡ ▪ Charts ¡(Jfreechart) ¡ ▪ Report ¡trigger ¡ ▪ Subreports ¡/ ¡modulariza&on ¡/ ¡reusuability ¡ ▪ Condi&onal ¡formajng ¡(styles) ¡ ▪ Condi&onal ¡rendering ¡of ¡elements ¡ ¡ ▪ Scrip&ng ¡languages, ¡especially ¡for ¡condi&ons ¡and ¡calcula&ons: ¡Java, ¡Groovy, ¡ Javascript ¡ ▪ Fonts, ¡Unicode, ¡NLS ¡ ▪ ... ¡
► Visual ¡report ¡layout ¡with ¡the ¡iReport ¡designer ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 31
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 32
► Integra&on ¡with ¡APEX ¡ ► 1: ¡Client ¡clicks ¡on ¡a ¡link ¡ ¡ ¡ ► 2: ¡APEX ¡calls ¡the ¡JasperIntegra&on ¡in ¡ ¡ ¡ ¡ ¡ ¡the ¡J2EE ¡Server ¡(Tomcat) ¡and ¡passes ¡ ¡ ¡ ¡ ¡just ¡the ¡parameters ¡(report_name, ¡ ¡ ¡ ¡ ¡ ¡connect ¡informa&on, ¡report ¡parameters) ¡ ► 3: ¡JasperReports ¡starts ¡a ¡database ¡connec&on ¡ ¡ ¡ ¡ ¡and ¡generates ¡the ¡report ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 33
► Integra&on ¡Kit ¡available: ¡ h[p://www.opal-‑consul&ng.de/tools ¡ ► License: ¡BSD ¡– ¡do ¡whatever ¡you ¡like ¡but ¡ don‘t ¡sue ¡me ¡ ► Indepth ¡analysis ¡of ¡use ¡cases ¡for ¡moving ¡ from ¡Oracle ¡Reports ¡to ¡JasperReports ¡at ¡ KScope ¡2012 ¡ ► Step ¡by ¡step ¡integra&on ¡into ¡the ¡sample ¡ applica&on: ¡
h[p://www.opal-‑consul&ng.de/downloads/ free_tools/JasperReportsIntegra&on/Opal-‑ Consul&ng-‑JasperReportsIntegra&on.pdf ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 34
► Concep&onally ¡expose ¡repor&ng ¡func&onality ¡using ¡an ¡URL ¡based ¡interface ¡ which ¡passes ¡parameters ¡and ¡just ¡triggers ¡the ¡execu&on ¡of ¡a ¡report ¡ somewhere ¡else, ¡then ¡returns ¡the ¡generated ¡document. ¡ ► Integra&on ¡typically ¡uses ¡UTL_HTTP ¡or ¡APEX_WEB_SERVICE ¡ ► Thus, ¡all ¡kinds ¡of ¡engines ¡can ¡be ¡used: ¡ ¡
▪ Oracle ¡Reports, ¡Chrystal ¡Reports, ¡Eclipse ¡BIRT ¡ ▪ Business ¡Objects ¡ ▪ ... ¡
► Powerful ¡engines, ¡perhaps ¡already ¡installed ¡in ¡your ¡corpora&on ¡ ¡ ► You ¡have ¡to ¡deal ¡with ¡security, ¡though. ¡SSO ¡might ¡be ¡challenging ¡but ¡there ¡ are ¡simple ¡workarounds. ¡ ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 35
► PL-‑jrxml2pdf ¡h[p://sourceforge.net/projects/pljrxml2pdf/ ¡ ¡ ► Open ¡Source ¡project ¡developed ¡by ¡Andreas ¡Weiden ¡ ► License: ¡MIT ¡ ► The ¡concept ¡
▪ Design ¡your ¡report ¡layout ¡using ¡the ¡iReport ¡Designer ¡/ ¡Jaspersoi ¡Studio ¡ ▪ Use ¡a ¡pure ¡PL/SQL ¡based ¡run&me ¡engine ¡based ¡on ¡the ¡package ¡AS_PDF3 ¡wri[en ¡ by ¡Anton ¡Scheffer ¡to ¡process ¡the ¡.jrxml ¡defini&on ¡file ¡
► Use ¡a ¡GUI ¡tool ¡design ¡your ¡reports ¡(live ¡jdbc ¡connec&on ¡and ¡preview) ¡ ► Deploy ¡it ¡in ¡a ¡pure ¡PL/SQL ¡environment ¡ ► Does ¡not ¡support ¡all ¡of ¡the ¡JasperReports ¡features, ¡but ¡very ¡many ¡ ► Can ¡always ¡move ¡the ¡defini&ons ¡to ¡a ¡„real“ ¡, ¡java ¡based ¡run&me ¡ ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 36
► Features ¡
▪ Text ¡styling, ¡condi&onal ¡styling, ¡frames, ¡borders, ¡colors ¡ ▪ Condi&onal ¡rendering, ¡basic ¡Java ¡operators ¡(+,-‑,=,>, ¡AND, ¡OR, ¡NOT, ¡IS ¡NULL, ¡...) ¡ are ¡translated ¡to ¡pl/sql ¡ ▪ Report ¡tables ¡ ▪ Crosstabs ¡ ▪ Subreports ¡ ▪ Groups ¡ ▪ Custom ¡Fonts ¡ ▪ Images ¡ ▪ NLS-‑support, ¡also ¡transla&ons ¡using ¡Resource ¡Files ¡ ▪ Charts ¡ ▪ Genera&ng ¡a ¡single ¡PDF ¡from ¡mul&ple ¡report ¡defini&ons ¡ ▪ HTML ¡field ¡support ¡(basic) ¡ ▪ Google ¡Map ¡Images ¡ ▪ JRXML-‑Generator ¡for ¡quickly ¡crea4ng ¡a ¡basic ¡report ¡defini4on ¡file ¡from ¡an ¡APEX ¡ page ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 37
► Doxxy ¡by ¡iAdvise ¡( ¡h[p://www.doxxy.eu/ ¡) ¡ ► The ¡concept ¡
▪ Take ¡an ¡exis&ng ¡MS ¡Word ¡(docx) ¡document ¡and ¡put ¡placeholders ¡in ¡it ¡ ▪ Pure ¡PL/SQL ¡based ¡solu&on ¡(the ¡PDF ¡converter ¡uses ¡an ¡a ¡Java ¡callout ¡to ¡the ¡OS ¡to ¡ call ¡Aspose.PDF ¡/ ¡embedded ¡license ¡included) ¡ ▪ At ¡run&me ¡parses ¡the ¡docx ¡xml ¡structures ¡and ¡replaces ¡the ¡variables ¡
► License: ¡1500€ ¡per ¡database ¡(docx ¡only) ¡
▪ 2000€ ¡(docx ¡+ ¡pdf), ¡uses ¡an ¡external ¡process ¡on ¡the ¡DB ¡host ¡(Aspose.PDF) ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 38
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 39
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 40
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 41
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 42
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 43
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 44
► Use ¡a ¡familiar ¡GUI ¡environment ¡=> ¡MS ¡Word ¡ ► Runs ¡in ¡a ¡pure ¡PL/SQL ¡environment ¡ ► Generates ¡a ¡„true“ ¡MS ¡Word ¡document ¡ ► Cannot ¡handle ¡complex ¡repor&ng ¡requirements ¡ ¡ ¡
Integra&on ¡Strategies ¡for ¡APEX ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 45
25.03.2014 Reporting Solutions for Oracle APEX Page 46
► Excel ¡interprets ¡and ¡modifies ¡the ¡data ¡automa4cally! ¡
▪ Street ¡No. ¡is ¡interpreted ¡either ¡as ¡text ¡or ¡number ¡(11, ¡11a) ¡ ▪ Zip-‑code: ¡01067 ¡is ¡converted ¡to ¡number ¡1067 ¡leading ¡zeroes ¡are ¡lost!!! ¡ ▪ Ident-‑Codes ¡> ¡12 ¡digits ¡ ¡=> ¡converts ¡to ¡scien&fic ¡nota&on ¡(E+18) ¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 47
► Regular ¡APEX ¡Export ¡to ¡CSV ¡when ¡using ¡Interac&ve ¡Reports ¡
▪ Workaround ¡to ¡properly ¡display ¡leading ¡zeroes ¡in ¡the ¡CSV ¡export ¡ ▪ => ¡Force ¡data ¡type ¡text ¡(e.g. ¡for ¡04178 ¡format ¡as ¡formula: ¡ ¡="04178" ¡) ¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 48
select ¡ ¡ ¡country ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡ident ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡customer ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡customer_registered_on ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡customer_period ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡sum_of_purchases ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡street ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡street_no ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡city ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡decode(:request, ¡'CSV', ¡'="'||zip||'"', ¡zip) ¡zip ¡ ¡ ¡from ¡jdd_csv_demo ¡
► Workaround ¡does ¡not ¡work ¡for ¡interac&ve ¡reports! ¡=> ¡CSV ¡is ¡empty! ¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 49 ¡select ¡"CUSTOMER", ¡"CUSTOMER_PERIOD", ¡"CUSTOMER_REGISTERED_ON" ¡, ¡"SUM_OF_PURCHASES", ¡ "IDENT", ¡ ¡ ¡"STREET", ¡"STREET_NO" ¡, ¡"CITY", ¡"ZIP", ¡"COUNTRY”, ¡ ¡count(*) ¡over ¡() ¡as ¡apxws_row_cnt ¡ ¡ ¡ from ¡ ¡ ¡(select ¡* ¡ ¡ ¡ ¡ ¡ ¡from ¡ ¡ ¡ ¡ ¡(select ¡country ¡, ¡ident ¡, ¡customer ¡, ¡customer_registered_on ¡, ¡customer_period ¡, ¡ ¡ ¡ ¡ ¡ ¡ ¡sum_of_purchases ¡, ¡street ¡, ¡street_no ¡, ¡city ¡, ¡decode(:request, ¡'CSV', ¡'="'||zip||'"', ¡ zip) ¡zip ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡from ¡jdd_csv_demo ¡ ¡ ¡ ¡ ¡) ¡r ¡ ¡ ¡ ¡ ¡where("ZIP" ¡= ¡:APXWS_EXPR_1) ¡ ¡ ¡) ¡r ¡ ¡ ¡where ¡rownum ¡<= ¡to_number(:APXWS_MAX_ROW_CNT); ¡
04178 = =“04178“
► Manual ¡export ¡to ¡CSV ¡with ¡stored ¡procedure ¡
▪ h[p://spendolini.blogspot.de/2006/04/custom-‑export-‑to-‑csv.html ¡ ¡ ▪ h[p://www.astral-‑consultancy.co.uk/cgi-‑bin/hunbug/doco.cgi?11270 ¡ ¡
► Manual ¡export ¡to ¡HTML ¡with ¡stored ¡procedure, ¡set ¡Mime-‑Type=MS ¡Excel ¡
▪ h[p://roelhartman.blogspot.de/2006/07/how-‑to-‑create-‑neatly-‑forma[ed-‑excel.html ¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 50
► Plugins, ¡e.g. ¡by ¡Anton ¡Scheffer ¡
▪ h[p://apex-‑plugin.com/oracle-‑apex-‑plugins/process-‑type-‑plugin/ir-‑report-‑to-‑excel-‑ xlsx_74.html ¡ ¡ ▪ Exports ¡with ¡correct ¡data ¡types ¡ ▪
▪ Does ¡not ¡respect: ¡ − The ¡selected ¡columns ¡(and ¡their ¡order), ¡the ¡filter ¡or ¡the ¡sort ¡order ¡ ¡ ▪ Always ¡just ¡outputs ¡the ¡base ¡sql ¡statement ¡of ¡the ¡interac&ve ¡report ¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 51
► The ¡new ¡APEX ¡4.2 ¡APIs ¡allow ¡us ¡to ¡retrieve ¡run&me ¡ query ¡of ¡the ¡interac&ve ¡report: ¡ ► APEX_IR.GET_REPORT ¡ ► APEX_IR.GET_LAST_VIEWED_REPORT_ID ¡ ► Created ¡a ¡plugin ¡for ¡the ¡interac&ve ¡report ¡using ¡the ¡ OPAL::XP ¡Publisher ¡by ¡OPAL-‑Consul&ng ¡ ► Added ¡a ¡dynamic ¡ac&on ¡(plugin) ¡to ¡page ¡0, ¡is ¡ automa&cally ¡a[ached ¡to ¡all ¡interac&ve ¡reports ¡in ¡the ¡ applica&on ¡ ¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡– ¡OPAL::XP ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 52
¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡– ¡OPAL::XP ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 53
► OPAL::XP ¡(h[p://www.opal-‑consul&ng.de/) ¡ ► Templa&ng ¡approach ¡to ¡add ¡data ¡to ¡your ¡na&ve ¡MS ¡Excel ¡Sheet ¡(.xls ¡/ ¡.xlsx) ¡on ¡the ¡fly ¡ ► The ¡Concept: ¡
− E.g: ¡alias_d ¡for ¡the ¡order ¡informa&on: ¡
alias>.<column ¡name>}: ¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡– ¡OPAL::XP ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 54
SELECT ¡product_name, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡quantity, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡order_timestamp, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡category, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡sales ¡ ¡ ¡FROM ¡demo_orders ¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 55
Major ¡Use ¡Cases ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 56
► Use ¡MS ¡Excel ¡to ¡format ¡your ¡export ¡ ► Correct ¡data ¡type ¡export ¡ ► Usage ¡of ¡na&ve ¡MS ¡Excel ¡features: ¡Export ¡mul&ple ¡worksheets ¡at ¡the ¡same ¡ &me, ¡autofilter, ¡macros, ¡condi&onal ¡formajng, ¡Show ¡/ ¡hide ¡columns, ¡Charts, ¡ Pivot-‑tables, ¡password ¡protec&on ¡for ¡files ¡and ¡worksheets ¡ ► Includes ¡template ¡syntax ¡to ¡support ¡more ¡complex ¡template ¡structures, ¡but ¡ the ¡simple ¡approach ¡is ¡in ¡most ¡cases ¡absolutely ¡sufficient ¡ ► Architecture: ¡Uses ¡external ¡web ¡service, ¡communica&on ¡via ¡utl_h[p ¡ ► License: ¡ ¡
▪ 1500€ ¡per ¡dedicated ¡applica&on ¡(ASFU) ¡ ▪ 7500€ ¡per ¡server ¡
► Prototype ¡implementa&on ¡included ¡for ¡the ¡first ¡implementa&on! ¡
Data ¡Export ¡ Export ¡with ¡proper ¡data ¡types ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 57
25.03.2014 Reporting Solutions for Oracle APEX Page 58
► At ¡the ¡clients ¡you ¡will ¡find ¡a ¡colorful ¡mix ¡of ¡all ¡the ¡solu&ons ¡
▪ PL/PDF ¡used ¡quite ¡oien ¡ ▪ People ¡shy ¡away ¡from ¡reques&ng ¡addi&onal ¡infrastructure, ¡the ¡DB ¡“people” ¡ prefer ¡solu&ons ¡with ¡less ¡moving ¡parts ¡=> ¡thus ¡prefer ¡a ¡pl/sql ¡only ¡solu&on ¡
► It ¡all ¡depends ¡on ¡your ¡use ¡case ¡and ¡context ¡
▪ Is ¡the ¡repor&ng ¡used ¡for ¡APEX ¡only? ¡ ▪ Do ¡you ¡need ¡batch ¡processing? ¡ ▪ Is ¡the ¡development ¡of ¡the ¡reports ¡independent ¡of ¡the ¡APEX ¡development? ¡Who ¡ does ¡it? ¡ ▪ Can ¡a ¡we ¡use ¡a ¡J2EE ¡server ¡for ¡the ¡addi&onal ¡func&onality? ¡
► Oracle ¡BI ¡Publisher ¡ ¡
▪ Perfect ¡fit ¡for ¡the ¡different ¡use ¡cases ¡ ▪ Just ¡very ¡expensive ¡
Discussion ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 59
► Personally, ¡I ¡would ¡use ¡different ¡tools ¡to ¡handle ¡the ¡different ¡output ¡formats: ¡
▪ PDF, ¡MS ¡Word, ¡MS ¡Excel ¡
▪ Why? ¡ ¡
▪ Completely ¡different ¡use ¡cases ¡ ▪ The ¡generated ¡MS ¡Word ¡or ¡MS ¡Excel ¡is ¡not ¡na&ve ¡and ¡cannot ¡be ¡easily ¡changed ¡
► When ¡evalua&ng, ¡TRY ¡to ¡implement ¡YOUR ¡maximum ¡requirements ¡
▪ Which ¡formats ¡for ¡what ¡purpose? ¡PDF, ¡MS ¡Word ¡and ¡MS ¡Excel ¡required? ¡ ▪ Mul&-‑language ¡capable? ¡NLS ¡(number, ¡dates) ¡and ¡Labels? ¡ ▪ Formajng? ¡ ▪ Mul&ple ¡queries ¡(master-‑detail-‑detail, ¡etc.)? ¡ ▪ Using ¡images ¡as ¡Blobs ¡or ¡via ¡URLs? ¡
Discussion ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 60
► Use ¡a ¡pragma&c ¡approach, ¡use ¡what ¡is ¡already ¡there ¡=> ¡URL ¡based ¡integra&on ¡ using ¡an ¡exis&ng ¡infrastructure. ¡ ► I ¡always ¡like ¡to ¡ques&on ¡whether ¡you ¡actually ¡NEED ¡PDF, ¡MS ¡Word ¡or ¡true ¡MS ¡ Excel, ¡because ¡it ¡is ¡difficult ¡and ¡costly. ¡ ► Crea&ng ¡a ¡pixel ¡perfect ¡design ¡for ¡PDF ¡is ¡PAINFUL. ¡
Discussion ¡
25.03.2014 Reporting Solutions for Oracle APEX Page 61
25.03.2014 Reporting Solutions for Oracle APEX Page 62
Dietmar ¡Aust ¡ Opal-‑Consul&ng, ¡Köln ¡ ¡ www.opal-‑consul&ng.de ¡ daust.blogspot.com ¡ dietmar.aust@opal-‑consul&ng.de ¡