翻譯|使用教程|編輯:王香|2018-11-08 10:52:23.000|閱讀 863 次
概述:此示例項(xiàng)目顯示如何使用MySQL字段創(chuàng)建新報(bào)表并提取MySQL數(shù)據(jù)庫(kù)信息。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
此示例項(xiàng)目顯示如何使用MySQL字段創(chuàng)建新報(bào)表并提取MySQL數(shù)據(jù)庫(kù)信息。
首先,您需要?jiǎng)?chuàng)建一個(gè)新報(bào)表并添加MySqlDatabase。在StiMySqlDatabase類的構(gòu)造函數(shù)中,您應(yīng)該設(shè)置數(shù)據(jù)庫(kù)名稱,別名和連接字符串。
public static StiReport createReport() throws ClassNotFoundException, SQLException, StiException, FileNotFoundException { StiReport report = StiReport.newInstance(); StiPage page = report.getPages().get(0); report.setDictionary(new StiDictionary(report)); StiMySqlDatabase db = new StiMySqlDatabase( "test", "test"%t.setName("DataText" + nameIndex.toString()); dataText.getBorder().setSide(StiBorderSides.All); dataBand.getComponents().add(dataText); pos = pos + columnWidth; nameIndex++; } ...
最后,使用報(bào)表對(duì)象的Render()方法呈現(xiàn)創(chuàng)建的報(bào)表,并返回結(jié)果。
... report.Render(); return report; }
要顯示報(bào)表,我們使用本機(jī)Java查看器。我們需要?jiǎng)?chuàng)建查看器對(duì)象,添加必要的事件偵聽(tīng)器并分配報(bào)表。
public static void showReport(StiReport report) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setPreferredSize(new Dimension(1000, 1000)); StiViewerFx viewerPanel = new StiViewerFx(frame); panel.add(viewerPanel); frame.add(panel); frame.setSize(new Dimension(1000, 1000)); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); viewerPanel.getStiViewModel().getEventDispatcher() .dispatchStiEvent(new StiViewCommonEvent(StiViewCommonEvent.DOCUMENT_FILE_LOADED, new StiDocument(report), null)); } public static void main(String[] args) throws ClassNotFoundException, SQLException, StiException, FileNotFoundException { StiReport report = createReport(); showReport(report); }
示例代碼的結(jié)果如下圖所示:
購(gòu)買Stimulsoft正版授權(quán),請(qǐng)點(diǎn)擊“”喲!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn