JavaScript Object Notation (JSON) is a text-based data format in which the data is stored in the hierarchical form. You can use the JsonRenderingExtension to render your report in this format.
The following steps provide an example of rendering a report in the Json format.
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
' Provide the page report you want to render. Dim report As New GrapeCity.ActiveReports.PageReport() Dim reportDocument As New GrapeCity.ActiveReports.Document.PageDocument(report) ' Create an output directory. Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyJSON") outputDirectory.Create() ' Provide settings for your rendering output. Dim jsonSettings As New GrapeCity.ActiveReports.Export.Text.Page.JsonRenderingExtension.Settings() jsonSettings.Formatted = True ' Set the rendering extension and render the report. Dim jsonRenderingExtension As New GrapeCity.ActiveReports.Export.Text.Page.JsonRenderingExtension() Dim outputProvider As 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) |
C# code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
// 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); |