//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); // Load template file from resource Stream templateFile = this.GetResourceStream("xlsx\\ComplexMultiDataSource.xlsx"); workbook.Open(templateFile); // Create table data sources from JSON JsonTable order = new JsonTable(this.GetResourceStream("json\\order.json")); JsonTable customer = new JsonTable(this.GetResourceStream("json\\customer.json")); JsonTable product = new JsonTable(this.GetResourceStream("json\\product.json")); // Add data sources workbook.AddDataSource("order", order); workbook.AddDataSource("customer", customer); workbook.AddDataSource("product", product); // Invoke to process the template workbook.ProcessTemplate(); workbook.Worksheets[0].Range["A:F"].ColumnWidth = 16; // Save to an excel file workbook.Save("CustomDataTable.xlsx");
' Create a new Workbook Dim workbook As New Workbook ' Load template file from resource Dim templateFile As Stream = GetResourceStream("xlsx\ComplexMultiDataSource.xlsx") workbook.Open(templateFile) ' Create table data sources from JSON Dim order As New JsonTable(GetResourceStream("json\order.json")) Dim customer As New JsonTable(GetResourceStream("json\customer.json")) Dim product As New JsonTable(GetResourceStream("json\product.json")) ' Add data sources workbook.AddDataSource("order", order) workbook.AddDataSource("customer", customer) workbook.AddDataSource("product", product) ' Invoke to process the template workbook.ProcessTemplate() workbook.Worksheets(0).Range("A:F").ColumnWidth = 16 ' save to an excel file workbook.Save("CustomDataTable.xlsx")