javascript
ActiveReports 报表控件V12新特性 -- 新增JSON和CSV导出
ActiveReports 是一款專注于 .NET 平臺的報表控件,全面滿足 HTML5 / WinForms / ASP.NET / ASP.NET MVC / WPF 等平臺下報表設(shè)計和開發(fā)工作需求,作為專業(yè)的報表工具為全球超過 300,000 開發(fā)人員提供了全面的報表開發(fā)服務(wù)。
?
最新發(fā)布的ActiveReports 12推出了兩種新的導(dǎo)出模式 JSON和CSV, 這些導(dǎo)出功能類似于我們的其他接口,如PDF,Doc,Docx和HTML,只需要幾行代碼,就可以實現(xiàn)。
?
一、 導(dǎo)出 JSON
JSON(JavaScript Object Notation) 是一種輕量級的數(shù)據(jù)交換格式。JSON采用完全獨立于語言的文本格式,這些特性使JSON成為理想的數(shù)據(jù)交換語言
1、在報表設(shè)計器中導(dǎo)出JSON模式,具體操作如下:
2、代碼中實現(xiàn):
// Provide the page report you want to render. GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(); GrapeCity.ActiveReports.Document.PageDocument reportDocument = new GrapeCity.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 = new GrapeCity.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);?
二、 導(dǎo)出CSV
CSV逗號分隔值文件(Comma Separated value),是一種用來存儲數(shù)據(jù)的純文本文件格式。CSV是一種通用的文件格式,它可以非常容易的被導(dǎo)入各種PC表格及數(shù)據(jù)庫中,CSV文件中的一行即就是數(shù)據(jù)表中的一行。
1、在報表設(shè)計器中導(dǎo)出CSV模式,具體操作如下:
2、代碼中實現(xiàn):
// Provide the page report you want to render. GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(); GrapeCity.ActiveReports.Document.PageDocument reportDocument = new GrapeCity.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 = new GrapeCity.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);定制培訓(xùn)加量全心送!凡在2017年12月31日之前,購買葡萄城控件團隊授權(quán)和企業(yè)授權(quán)的用戶,不僅可以享受到優(yōu)惠的價格,還可獲贈葡萄城技術(shù)專家根據(jù)客戶項目需求提供的定制培訓(xùn)服務(wù)。老客戶推薦新客戶成單,也將獲得“客戶推薦雙重感恩禮”。
點擊此處,了解更多。
?
關(guān)于葡萄城報表
葡萄城報表是一套強大的報表開發(fā)和系統(tǒng)搭建工具,既能與您開發(fā)的報表軟件項目緊密集成,也可獨立部署運行,支持多數(shù)據(jù)源,具有無編碼、靈活、穩(wěn)定等特性,可以幫您快速搭建專業(yè)的報表軟件系統(tǒng),實現(xiàn)各類報表的設(shè)計、管理、權(quán)限控制、數(shù)據(jù)填報、負載均衡及跨平臺發(fā)布。
千萬種報表,同一種選擇!獲知葡萄城報表更多詳情,請訪問如下網(wǎng)站:
了解報表開發(fā)控件:http://www.gcpowertools.com.cn/products/activereports_overview.htm
了解報表服務(wù)器:http://www.grapecity.com.cn/enterprise-solutions/activereports_server/
轉(zhuǎn)載于:https://www.cnblogs.com/chunsunbajie/p/json_csv.html
總結(jié)
以上是生活随笔為你收集整理的ActiveReports 报表控件V12新特性 -- 新增JSON和CSV导出的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: myecplise新建Maven项目Fi
- 下一篇: 孕妇梦到猫狗是什么意思