stimulsoft mysql_【Stimulsoft Reports Java教程】在运行时使用MySQL数据库创建报表

stimulsoft mysql_【Stimulsoft Reports Java教程】在运行时使用MySQL数据库创建报表此示例项目显示如何使用MySQL字段创建新报表并提取MySQL数据库信息。首先,您需要创建一个新报表并添加MySqlDatabase。在StiMySqlDatabase类的构造函数中,您应该设置数据库名称,别名和连接字符串。publicstaticStiReportcreateReport()throwsClassNotFoundException,SQLException,StiE…

大家好,又见面了,我是你们的朋友全栈君。

此示例项目显示如何使用MySQL字段创建新报表并提取MySQL数据库信息。

首先,您需要创建一个新报表并添加MySqlDatabase。在StiMySqlDatabase类的构造函数中,您应该设置数据库名称,别名和连接字符串。

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&quot%t.setName(“DataText” + nameIndex.toString());

dataText.getBorder().setSide(StiBorderSides.All);

dataBand.getComponents().add(dataText);

pos = pos + columnWidth;

nameIndex++;

}

…

最后,使用报表对象的Render()方法呈现创建的报表,并返回结果。

…

report.Render();

return report;

}

要显示报表,我们使用本机Java查看器。我们需要创建查看器对象,添加必要的事件侦听器并分配报表。

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);

}

示例代码的结果如下图所示:

833a2f0cccdde35bdcc5878573053740.png

购买Stimulsoft正版授权,请点击“咨询在线客服”哟!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/158835.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长

相关推荐

  • springboot连接多个数据库

    springboot连接多个数据库今天接到一个新的需求,需要把自己数据库某个表的数据迁移到别的数据库中,于是百度,中间出现了一些细节的问题,解决花了点时间,在此记录一下,下次避免出现过的错误这里把连接一个数据库的情况也记录一下,好做对比一、连接一个数据库1.启动类@SpringBootApplication//扫描mapper映射类所在路径@MapperScan(basePackages="com.xh….

    2022年6月25日
  • phpstrom2021激活码 3月最新注册码

    phpstrom2021激活码 3月最新注册码,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月14日
  • phpspreadsheet使用实例_php获取html中文本框内容

    phpspreadsheet使用实例_php获取html中文本框内容目录安装引用导入Excel获取日期格式安装composerrequirephpoffice/phpspreadsheet引用usePhpOffice\PhpSpreadsheet\Reader\Xlsx;usePhpOffice\PhpSpreadsheet\Reader\Xls;usePhpOffice\PhpSpreadsheet\IOFactory;usePhpOffice\PhpSpreadsheet\Cell\Coordinate;usePhpOffice\PhpS

    2022年9月17日
  • Windows查看端口占用情况_windows关闭端口命令

    Windows查看端口占用情况_windows关闭端口命令步骤1.win+R快捷键启动运行,输入cmd命令,打开小黑窗口2.在命令窗口中输入“netstat-ano”命令,回车,就可看到系统当前所有端口的占用情况3.输入“netstat-ano|findstr“端口号””命令,回车,就可以看到指定端口的占用情况……

    2022年7月27日
  • executequery方法返回值_mysql数据库有什么用

    executequery方法返回值_mysql数据库有什么用1if(AccessCon.ExecuteSql(sql=”select*fromsalesDatawhereindex='”+man.Index+”‘”)>0)2{3retValue=AccessCon.ExecuteSql(sql=”updatesalesDatasetsellingPrize='”+m…

    2022年9月11日
  • python socket recvfrom_Python:socket.recvfrom()不返回任何地址

    python socket recvfrom_Python:socket.recvfrom()不返回任何地址我正在尝试编写示例here的Python版本,但是由于某种原因,我在客户端和服务器中对socket.recvfrom()的每次调用都将其地址返回值为None.我唯一能想到的可能是套接字是STREAM套接字,但是当我尝试将类型更改为socket.SOCK_DGRAM时,调用socket.listen()时出错.我该如何解决这个问题?defserver(port):sock=socket.soc…

    2022年7月23日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号