您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

C#初步体验FastReport 报表(图)

2024/6/5 19:16:37发布30次查看
原来程序使用的word和excel来做一些导出数据和打印的操作,可是运行一段时间发现总有一些用户的电脑上安装的office有些问题,还需要重新安装调整造成一些额外的维护工作。
这里通过简单尝试使用fastreport来代替office,将一些需要导出的数据以报表的形式生成,需要的话可以另存成excel格式,这样就能减少一些不必要的麻烦。
程序里将连接信息从报表中提出来,避免报表文件的不安全,另外这个连接信息可以单独做到配置文件中即可。
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; using system.data.sqlclient; namespace 测试fastreport { public partial class form1 : form { private dataset data; public form1() { initializecomponent(); } private void button1_click(object sender, eventargs e) { string constr = "server='127.0.0.1';initial catalog=waimaojinkou;uid='sa';pwd='12345';max pool size=512;"; try { sqlconnection con = new sqlconnection(constr); con.open(); sqlcommand sqlcmd = new sqlcommand(); sqlcmd.connection = con; sqlcmd.commandtext = @"select * from [event] "; sqldataadapter sda = new sqldataadapter(sqlcmd); data = new dataset(); sda.fill(data); con.close(); sda.dispose(); } catch (exception err) { messagebox.show(err.stacktrace); } try { fastreport.report report = new fastreport.report(); //string filename = application.startuppath + @"\frxreport\qualityevent.frx"; string filename = @"d:\qualityevent.frx"; report.load(filename); report.registerdata(data); report.getdatasource(data.tables[0].tablename).enabled = true; report.show(); } catch (exception err) { messagebox.show(err.message); } } } }
试了几次,只有使用.net4.0的时候,fastreport才会被识别出来,所以开发的项目也需要重新设置一下,重新安装.net4.0的框架包。
以上就是c#初步体验fastreport 报表(图)的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product