birt報(bào)表動態(tài)切換數(shù)據(jù)源解決方案_第1頁
birt報(bào)表動態(tài)切換數(shù)據(jù)源解決方案_第2頁
birt報(bào)表動態(tài)切換數(shù)據(jù)源解決方案_第3頁
birt報(bào)表動態(tài)切換數(shù)據(jù)源解決方案_第4頁
birt報(bào)表動態(tài)切換數(shù)據(jù)源解決方案_第5頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上Birt報(bào)表動態(tài)切換數(shù)據(jù)源解決方案陳鴻編寫(一) 通過 library實(shí)現(xiàn)連接數(shù)據(jù)庫管理1. 理解library(庫):可視化的報(bào)表開發(fā)環(huán)境。可以理解為,在使用創(chuàng)建報(bào)表的時候有很多的報(bào)表資源都會重復(fù)的使用,這樣為了方便管理,可以將這些部分放在library文件里,這樣其它報(bào)表只要是引用這些library文件即可。同時也方便了管理,例如當(dāng)修改數(shù)據(jù)源的時候,只要修改包含數(shù)據(jù)源的library文件就可以了,而不必去一個個修改其它的報(bào)表文件。這些庫可包含任何報(bào)表元素,比如樣式、數(shù)據(jù)源、報(bào)表?xiàng)l目、腳本等等。2. 創(chuàng)建library:增加到應(yīng)用中用于運(yùn)行報(bào)表,并可以把報(bào)表以各種形

2、式導(dǎo)出,如Excel、HTML分頁格式、PDF、RTF等。A 選新建LibraryB 可以看到新類似于創(chuàng)建報(bào)表文件的界面C 選擇所需的驅(qū)動,并添加合法的數(shù)據(jù)源信息。D 創(chuàng)建數(shù)據(jù)源完成后,也可以繼續(xù)創(chuàng)建數(shù)據(jù)集。3. 使用libraryA 下面進(jìn)行報(bào)表文件的制作,制作過程中會用到這個library文件。新建一個報(bào)表文件。在視圖里選擇Library Explorer,右擊,添加剛才新建好的Library文件。添加完成后記得點(diǎn)上面的刷新。B 進(jìn)行引用,首先確保Data Explorer和Library Explorer同時在界面里顯示,之后便是將Library 里的我們要用的數(shù)據(jù)拖拽到Data Exp

3、lorer 自己的報(bào)表Data sources中。便完成了引用數(shù)據(jù)源。如果Library中還有其它我們要引用的部分也是同樣去操作。4. 在java中修改birt報(bào)表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四項(xiàng)的值,并重新設(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") / 對密碼進(jìn)行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)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論