//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); var activeSheet = workbook.ActiveSheet; IRange a1 = activeSheet.Range["A1"]; var dict = new Dictionary<string, object>() { {"TempData1", 1}, {"TempData2", "Temp value 2"}, {"TempData3", 3}, {"TempData4", "Temp value 4"} }; // Set temporary data to a range a1.Value = dict; // Display the custom object later var obj = (IReadOnlyDictionary<string, object>)a1.Value; var row = 1; foreach (var kv in obj) { activeSheet.Range["B" + row].Value = kv.Key; activeSheet.Range["C" + row].Value = kv.Value; row += 1; } // Arrange activeSheet.Columns.AutoFit(); activeSheet.Columns[0].Hidden = true; // Save to a pdf file workbook.Save("SetCustomRangeValue.pdf");
' Create a new Workbook Dim workbook As New Workbook Dim activeSheet = workbook.ActiveSheet Dim a1 As IRange = activeSheet.Range!A1 Dim dict As New Dictionary(Of String, Object) From { {"TempData1", 1}, {"TempData2", "Temp value 2"}, {"TempData3", 3}, {"TempData4", "Temp value 4"} } ' Set temporary data to a range a1.Value = dict ' Display the custom object later Dim obj = DirectCast(a1.Value, IReadOnlyDictionary(Of String, Object)) Dim row = 1 For Each kv In obj activeSheet.Range("B" & row).Value = kv.Key activeSheet.Range("C" & row).Value = kv.Value row += 1 Next ' Arrange activeSheet.Columns.AutoFit() activeSheet.Columns(0).Hidden = True ' save to a pdf file workbook.Save("SetCustomRangeValue.pdf")