ActiveReports 报表控件V12新特性 -- 新增JSON和CSV导出

来源:互联网 发布:阿里云香港服务器快吗 编辑:程序博客网 时间:2024/06/03 14:58

ActiveReports是一款专注于 .NET 平台的报表控件,全面满足 HTML5 / WinForms / ASP.NET / ASP.NET MVC / WPF 等平台下报表设计和开发工作需求,作为专业的报表工具为全球超过 300,000 开发人员提供了全面的报表开发服务。

 

最新发布的ActiveReports 12推出了两种新的导出模式 JSON和CSV, 这些导出功能类似于我们的其他接口,如PDF,Doc,Docx和HTML,只需要几行代码,就可以实现。

 

一、 导出 JSON

JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。JSON采用完全独立于语言的文本格式,这些特性使JSON成为理想的数据交换语言

1、在报表设计器中导出JSON模式,具体操作如下:

2、代码中实现:

// Provide the page report you want to render.GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport();GrapeCity.ActiveReports.Document.PageDocument reportDocument = newGrapeCity.ActiveReports.Document.PageDocument(report);// Create an output directory.System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyJSON");outputDirectory.Create();// Provide settings for your rendering output.GrapeCity.ActiveReports.Export.Text.Page.JsonRenderingExtension.Settings jsonSettings =new GrapeCity.ActiveReports.Export.Text.Page.JsonRenderingExtension.Settings();jsonSettings.Formatted = true;// Set the rendering extension and render the report.GrapeCity.ActiveReports.Export.Text.Page.JsonRenderingExtension jsonRenderingExtension= new GrapeCity.ActiveReports.Export.Text.Page.JsonRenderingExtension();GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = newGrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory,System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));// Overwrite output file if it already exists.outputProvider.OverwriteOutputFile = true;reportDocument.Render(jsonRenderingExtension, outputProvider, jsonSettings);

 

二、 导出CSV

CSV逗号分隔值文件(Comma Separated value),是一种用来存储数据的纯文本文件格式。CSV是一种通用的文件格式,它可以非常容易的被导入各种PC表格及数据库中,CSV文件中的一行即就是数据表中的一行。

1、在报表设计器中导出CSV模式,具体操作如下:

2、代码中实现:

// Provide the page report you want to render.GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport();GrapeCity.ActiveReports.Document.PageDocument reportDocument = newGrapeCity.ActiveReports.Document.PageDocument(report);// Create an output directory.System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyCSV");outputDirectory.Create();// Provide settings for your rendering output.GrapeCity.ActiveReports.Export.Text.Page.CsvRenderingExtension.Settings csvSettings =new GrapeCity.ActiveReports.Export.Text.Page.CsvRenderingExtension.Settings();csvSettings.ColumnsDelimiter = ",";csvSettings.RowsDelimiter = "\r\n";csvSettings.QuotationSymbol = '"';csvSettings.Encoding = Encoding.UTF8;// Set the rendering extension and render the report.GrapeCity.ActiveReports.Export.Text.Page.CsvRenderingExtension csvRenderingExtension =new GrapeCity.ActiveReports.Export.Text.Page.CsvRenderingExtension();GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = newGrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory,System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));// Overwrite output file if it already exists.outputProvider.OverwriteOutputFile = true;reportDocument.Render(csvRenderingExtension, outputProvider, csvSettings);

定制培训加量全心送!凡在2017年12月31日之前,购买葡萄城控件团队授权和企业授权的用户,不仅可以享受到优惠的价格,还可获赠葡萄城技术专家根据客户项目需求提供的定制培训服务。老客户推荐新客户成单,也将获得“客户推荐双重感恩礼”。

点击此处,了解更多。

 

关于葡萄城报表

葡萄城报表是一套强大的报表开发和系统搭建工具,既能与您开发的报表软件项目紧密集成,也可独立部署运行,支持多数据源,具有无编码、灵活、稳定等特性,可以帮您快速搭建专业的报表软件系统,实现各类报表的设计、管理、权限控制、数据填报、负载均衡及跨平台发布。

千万种报表,同一种选择!获知葡萄城报表更多详情,请访问如下网站:
了解报表开发控件:http://www.gcpowertools.com.cn/products/activereports_overview.htm
了解报表服务器:http://www.grapecity.com.cn/enterprise-solutions/activereports_server/

阅读全文
0 0
原创粉丝点击