//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); // Set worksheet layout and data IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["B:F"].ColumnWidth = 15; worksheet.Range["4:7"].RowHeight = 60; worksheet.Range["A:A"].ColumnWidth = 5; worksheet.Range["B2"].Value = "Data Matrix"; worksheet.Range["B2:F2"].Merge(true); worksheet.Range["B3:F3"].Value = new object[,]{ {"Server", "Data", "Default", "ECC100", "ECC200"} }; worksheet.Range["B4:C7"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["B4:C7"].VerticalAlignment = VerticalAlignment.Center; worksheet.Range["B2:F3"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["B2:F3"].VerticalAlignment = VerticalAlignment.Center; worksheet.Range["B4:C7"].Value = new object[,] { {"Police", "911"}, {"Telephone Directory Assistance", "411"}, { "Non-emergency Municipal Services", "311"}, {"Travel Info Call 511", "511"} }; worksheet.Range["B4:B7"].WrapText = true; worksheet.PageSetup.PrintGridlines = true; // Set formula for (var i = 4; i < 8; i++) { var value = "CONCAT(B" + i + ",\":\",C" + i + ")"; worksheet.Range["D" + i].Formula = "=BC_DataMatrix" + "(" + value + ")"; worksheet.Range["E" + i].Formula = "=BC_DataMatrix" + "(" + value + ", , ,\"ECC000\")"; worksheet.Range["F" + i].Formula = "=BC_DataMatrix" + "(" + value + ", , ,\"ECC200\")"; } // Save to a pdf file workbook.Save("DataMatrix.pdf");
' Create a new Workbook Dim workbook As New Workbook 'set worksheet layout And data Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range("B:F").ColumnWidth = 15 worksheet.Range("4:7").RowHeight = 60 worksheet.Range("A:A").ColumnWidth = 5 worksheet.Range!B2.Value = "Data Matrix" worksheet.Range("B2:F2").Merge(True) worksheet.Range("B3:F3").Value = New Object(,) { {"Server", "Data", "Default", "ECC100", "ECC200"} } worksheet.Range("B4:C7").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("B4:C7").VerticalAlignment = VerticalAlignment.Center worksheet.Range("B2:F3").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("B2:F3").VerticalAlignment = VerticalAlignment.Center worksheet.Range("B4:C7").Value = New Object(,) { {"Police", "911"}, {"Telephone Directory Assistance", "411"}, {"Non-emergency Municipal Services", "311"}, {"Travel Info Call 511", "511"}} worksheet.Range("B4:B7").WrapText = True worksheet.PageSetup.PrintGridlines = True 'set formula For i = 4 To 8 - 1 Dim value = "CONCAT(B" & i & ","":"",C" & i & ")" worksheet.Range("D" & i).Formula = "=BC_DataMatrix" & "(" & value & ")" worksheet.Range("E" & i).Formula = "=BC_DataMatrix" & "(" & value & ", , ,""ECC000"")" worksheet.Range("F" & i).Formula = "=BC_DataMatrix" & "(" & value & ", , ,""ECC200"")" Next ' save to a pdf file workbook.Save("DataMatrix.pdf")