//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); //Load template file Template_FamilyInfo.xlsx from resource var templateFile = this.GetResourceStream("xlsx\\Template_FamilyInfo.xlsx"); workbook.Open(templateFile); //Get data from json file string jsonText = string.Empty; using (Stream stream = this.GetResourceStream("Template_FamilyInfo.json")) using (StreamReader reader = new StreamReader(stream)) { jsonText = reader.ReadToEnd(); } // Create a JsonDataSource var datasource = new JsonDataSource(jsonText); //Add data source workbook.AddDataSource("ds", datasource); //Invoke to process the template workbook.ProcessTemplate();
' Create a new Workbook Dim workbook As New Workbook 'Load template file Template_FamilyInfo.xlsx from resource Dim templateFile = GetResourceStream("xlsx\Template_FamilyInfo.xlsx") workbook.Open(templateFile) 'Get data from json file Dim jsonText As String Using stream = GetResourceStream("Template_FamilyInfo.json"), reader As New StreamReader(stream) jsonText = reader.ReadToEnd() End Using 'Create a JsonDataSource Dim datasource As New JsonDataSource(jsonText) 'Add data source workbook.AddDataSource("ds", datasource) 'Invoke to process the template workbook.ProcessTemplate() ' save to an excel file workbook.Save("JsonFile.xlsx")