//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); //set worksheet layout and data IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["B:K"].ColumnWidth = 15; worksheet.Range["4:6"].RowHeight = 60; worksheet.Range["A:A"].ColumnWidth = 2; worksheet.Range["B2"].Value = "QR Code"; worksheet.Range["B2:K2"].Merge(true); worksheet.Range["I3:J3"].Merge(true); worksheet.Range["B3:H3"].Value = new object[,]{ {"Server", "Data", "Default", "Change errorCorrectionLevel", "Change model", "Change version", "Change mask"} }; worksheet.Range["I3"].Value = "Change connection and connectionNo"; worksheet.Range["K3:K5"].Value = new object[,] { {"Explain" }, {"No QR Code generated, barcode data is too short to create connection symbol."}, {"No QR Code generated, barcode data is too short to create connection symbol."} }; worksheet.PageSetup.PrintTitleColumns = "$A:$C"; worksheet.PageSetup.Orientation = PageOrientation.Landscape; worksheet.PageSetup.PrintGridlines = true; worksheet.Range["K4:K5"].Font.Color = Color.Red; worksheet.Range["K4:K5"].WrapText = true; worksheet.Range["B4:C6"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["B4:C6"].VerticalAlignment = VerticalAlignment.Center; worksheet.Range["B2:K3"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["B2:K3"].VerticalAlignment = VerticalAlignment.Center; worksheet.Range["B4:C6"].Value = new object[,] { {"Police", "911"}, {"Travel Info Call 511", "511"}, { "", "www.google.com"}, }; //set formula for (var i = 4; i < 7; i++) { worksheet.Range["D" + i].Formula = "=BC_QRCODE" + "(C" + i + ")"; worksheet.Range["E" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,\"H\")"; worksheet.Range["F" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,1)"; worksheet.Range["G" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,,8)"; worksheet.Range["H" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,,,3)"; worksheet.Range["I" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,,,,\"true\",0)"; worksheet.Range["J" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,,,,\"true\",1)"; }
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) 'set worksheet layout And data worksheet.Range("B:K").ColumnWidth = 15 worksheet.Range("4:6").RowHeight = 60 worksheet.Range("A:A").ColumnWidth = 2 worksheet.Range!B2.Value = "QR Code" worksheet.Range("B2:K2").Merge(True) worksheet.Range("I3:J3").Merge(True) worksheet.Range("B3:H3").Value = New Object(,) { {"Server", "Data", "Default", "Change errorCorrectionLevel", "Change model", "Change version", "Change mask"}} worksheet.Range!I3.Value = "Change connection and connectionNo" worksheet.Range("K3:K5").Value = New Object(,) { {"Explain"}, {"No QR Code generated, barcode data is too short to create connection symbol."}, {"No QR Code generated, barcode data is too short to create connection symbol."}} worksheet.PageSetup.PrintTitleColumns = "$A:$C" worksheet.PageSetup.Orientation = PageOrientation.Landscape worksheet.PageSetup.PrintGridlines = True worksheet.Range("K4:K5").Font.Color = Color.Red worksheet.Range("K4:K5").WrapText = True worksheet.Range("B4:C6").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("B4:C6").VerticalAlignment = VerticalAlignment.Center worksheet.Range("B2:K3").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("B2:K3").VerticalAlignment = VerticalAlignment.Center worksheet.Range("B4:C6").Value = New Object(,) { {"Police", "911"}, {"Travel Info Call 511", "511"}, {"", "www.google.com"}} 'set formula For i = 4 To 7 - 1 worksheet.Range("D" & i).Formula = "=BC_QRCODE" & "(C" & i & ")" worksheet.Range("E" & i).Formula = "=BC_QRCODE" & "(C" & i & ",,,""H"")" worksheet.Range("F" & i).Formula = "=BC_QRCODE" & "(C" & i & ",,,,1)" worksheet.Range("G" & i).Formula = "=BC_QRCODE" & "(C" & i & ",,,,,8)" worksheet.Range("H" & i).Formula = "=BC_QRCODE" & "(C" & i & ",,,,,,3)" worksheet.Range("I" & i).Formula = "=BC_QRCODE" & "(C" & i & ",,,,,,,""true"",0)" worksheet.Range("J" & i).Formula = "=BC_QRCODE" & "(C" & i & ",,,,,,,""true"",1)" Next ' save to a pdf file workbook.Save("QRCode.pdf")