//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); // Get data from json file. string jsonText = string.Empty; using (Stream stream = this.GetResourceStream("json\\DataBinding.json")) using (StreamReader reader = new StreamReader(stream)) { jsonText = reader.ReadToEnd(); } // jsonText content. // [ // {"Area": "North America","City": "Chicago","Category": "Consumer Electronics","Name": "Bose 785593-0050","Revenue": 92800}, // {"Area": "North America","City": "New York","Category": "Consumer Electronics","Name": "Bose 785593-0050","Revenue": 92800}, // {"Area": "South America","City": "Santiago","Category": "Consumer Electronics","Name": "Bose 785593-0050","Revenue": 19550} // ] IWorksheet worksheet = workbook.ActiveSheet; worksheet.DataSource = new JsonDataSource(jsonText); // Save to an excel file workbook.Save("JsonSource.xlsx");
' Create a new Workbook Dim workbook As New Workbook ' Get data from json file. Dim jsonText As String = String.Empty Using stream As Stream = Me.GetResourceStream("json\DataBinding.json") Using reader As New StreamReader(stream) jsonText = reader.ReadToEnd() End Using End Using ' jsonText content. ' [ ' {"Area": "North America","City": "Chicago","Category": "Consumer Electronics","Name": "Bose 785593-0050","Revenue": 92800}, ' {"Area": "North America","City": "New York","Category": "Consumer Electronics","Name": "Bose 785593-0050","Revenue": 92800}, ' {"Area": "South America","City": "Santiago","Category": "Consumer Electronics","Name": "Bose 785593-0050","Revenue": 19550} ' ] Dim worksheet As IWorksheet = workbook.ActiveSheet worksheet.DataSource = New JsonDataSource(jsonText) ' save to an excel file workbook.Save("JsonSource.xlsx")