




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上Birt報表動態(tài)切換數(shù)據(jù)源解決方案陳鴻編寫(一) 通過 library實現(xiàn)連接數(shù)據(jù)庫管理1. 理解library(庫):可視化的報表開發(fā)環(huán)境??梢岳斫鉃椋谑褂脛?chuàng)建報表的時候有很多的報表資源都會重復的使用,這樣為了方便管理,可以將這些部分放在library文件里,這樣其它報表只要是引用這些library文件即可。同時也方便了管理,例如當修改數(shù)據(jù)源的時候,只要修改包含數(shù)據(jù)源的library文件就可以了,而不必去一個個修改其它的報表文件。這些庫可包含任何報表元素,比如樣式、數(shù)據(jù)源、報表條目、腳本等等。2. 創(chuàng)建library:增加到應用中用于運行報表,并可以把報表以各種形
2、式導出,如Excel、HTML分頁格式、PDF、RTF等。A 選新建LibraryB 可以看到新類似于創(chuàng)建報表文件的界面C 選擇所需的驅(qū)動,并添加合法的數(shù)據(jù)源信息。D 創(chuàng)建數(shù)據(jù)源完成后,也可以繼續(xù)創(chuàng)建數(shù)據(jù)集。3. 使用libraryA 下面進行報表文件的制作,制作過程中會用到這個library文件。新建一個報表文件。在視圖里選擇Library Explorer,右擊,添加剛才新建好的Library文件。添加完成后記得點上面的刷新。B 進行引用,首先確保Data Explorer和Library Explorer同時在界面里顯示,之后便是將Library 里的我們要用的數(shù)據(jù)拖拽到Data Exp
3、lorer 自己的報表Data sources中。便完成了引用數(shù)據(jù)源。如果Library中還有其它我們要引用的部分也是同樣去操作。4. 在java中修改birt報表library的數(shù)據(jù)源/ 修改.rptlibrary內(nèi)的數(shù)據(jù)源信息 public void setDataSource(String rptdesignPath) DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; InputStream is = null; String datasource =
4、 null; Document doc = null; String EncodePsd = null; try db = dbf.newDocumentBuilder(); try is = new FileInputStream(rptdesignPath); try doc = db.parse(is); is.close(); catch (SAXException e) toPrint("SAXException"); return; catch (IOException e) toPrint("Can't read file " +
5、rptdesignPath + ""); return; catch (FileNotFoundException e) toPrint("Can't found file " + rptdesignPath + ""); return; catch (ParserConfigurationException e) / TODO Auto-generated catch block toPrint("ParserConfigurationException"); return; / 查找data-sourc
6、es信息 NodeList nodeList = doc.getElementsByTagName("data-sources"); for (int i = 0; i < nodeList.getLength(); i+) Element e = (Element) nodeList.item(i); NodeList properties = e.getChildNodes(); if (properties != null) / 得到oda-data-source部分信息 Node property = properties.item(1); for (Node
7、 node = property.getFirstChild(); node != null; node = node .getNextSibling() / 得到driver、url、username、password四項的值,并重新設(shè)置 if (node.getNodeName().equals("property") | node.getNodeName().equals("encrypted-property") String name = node.getAttributes().getNamedItem("name") .
8、getNodeValue(); if (name.equals("odaDriverClass") node.getFirstChild().setNodeValue(driver); else if (name.equals("odaURL") node.getFirstChild().setNodeValue(url); else if (name.equals("odaUser") node.getFirstChild().setNodeValue(username); else if (name.equals("od
9、aPassword") / 對密碼進行base64編碼 EncodePsd = (new sun.misc.BASE64Encoder() .encode(password.getBytes(); / System.out.println("*EncodePsd: / "+EncodePsd); node.getFirstChild().setNodeValue(EncodePsd); / 寫入指定的文件中 writeToXml(doc, rptdesignPath); / write to xml public void writeToXml(Document
10、doc, String rptdesign) try OutputStream fileoutputStream = new FileOutputStream(rptdesign); TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(fileoutputStream); transformer.transform(source, result); fileoutputStream.close(); catch (Exception e) toPrint("Can't write to file: &quo
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 個人公司合同范本
- 租賃房屋合同范本續(xù)租
- 室內(nèi)水泥漆合同范本
- 賓館培訓會議合同范本
- 6的乘法口訣(教學設(shè)計)-2024-2025學年人教版數(shù)學二年級上冊
- 8 冀中的地道戰(zhàn)(教學設(shè)計)-2024-2025學年統(tǒng)編版語文五年級上冊
- 9 我心中的“110”(教學設(shè)計)統(tǒng)編版道德與法治三年級上冊
- 2025年順酐酸酐衍生物項目發(fā)展計劃
- 1《神州謠》教學設(shè)計-2023-2024學年語文二年級下冊統(tǒng)編版
- 托管班合作協(xié)議書
- 披薩制作流程
- 廈門2025年福建廈門市公安文職人員服務(wù)中心招聘17人筆試歷年參考題庫附帶答案詳解
- 2025年高三歷史教學工作計劃
- 《職業(yè)性肌肉骨骼疾患的工效學預防指南 》
- 不同產(chǎn)地筠連紅茶風味化學成分差異分析
- DB50 577-2015 汽車整車制造表面涂裝大氣污染物排放標準
- 生態(tài)安全課件
- 大學英語(西安歐亞學院)知到智慧樹章節(jié)測試課后答案2024年秋西安歐亞學院
- 【化學】高中化學手寫筆記
- 膽管惡性腫瘤護理查房課件
- 電烤箱的使用方法ppt
評論
0/150
提交評論