// Create a pdf file stream using FileStream outputStream = new FileStream("FormControlMapPdfFormFieldBasicUsage.pdf", FileMode.Create); //create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet ws = workbook.Worksheets["Sheet1"]; ws.Range["$B$2:$C$2"].Value = new object[,] { { "Excel Form Control", "Mapped to form field"} }; ws.Range["$B$4"].Value = "Dropdown (Combo box)"; ws.Range["$B$6"].Value = "List box"; ws.Range["$B$11"].Value = "Option button"; ws.Range["$B$14"].Value = "Check box"; ws.Range["$B$2:$C$2"].Interior.ThemeColor = ThemeColor.Light2; ws.Range["$B$4"].VerticalAlignment = VerticalAlignment.Center; ws.Range["$B$14"].VerticalAlignment = VerticalAlignment.Center; ws.Range["$4:$4,$14:$14"].RowHeight = 18.6d; ws.Range["$11:$11"].RowHeight = 15.6d; ws.Range["$12:$12"].RowHeight = 26.4d; ws.Range["$B:$B"].ColumnWidthInPixel = 162d; ws.Range["$C:$C"].ColumnWidthInPixel = 214d; var ctl1 = ws.Controls.AddDropDown(177.3, 45.6, 141, 16.79); ctl1.Items.Add(new DropDownItem("Item 1")); ctl1.Items.Add(new DropDownItem("Item 2")); ctl1.Items.Add(new DropDownItem("Item 3")); ctl1.SelectedIndex = 0; var ctl2 = ws.Controls.AddListBox(177.9, 80.39, 140.4, 55.8); ctl2.Items.Add(new ListBoxItem("Item 1")); ctl2.Items.Add(new ListBoxItem("Item 2")); ctl2.Items.Add(new ListBoxItem("Item 3")); var ctl3 = ws.Controls.AddOptionButton(176.7, 152.4, 71.4, 17.39); ctl3.Text = "Option Button 1"; var ctl4 = ws.Controls.AddOptionButton(177.3, 175.2, 71.39, 16.80); ctl4.Text = "Option Button 2"; var ctl5 = ws.Controls.AddCheckBox(177.9, 211.79, 58.19, 16.80); ctl5.Text = "Check Box 1"; workbook.Save(outputStream, new PdfSaveOptions { FormFields = true }); // close the pdf stream outputStream.Close();
' Create a pdf file stream Dim outputStream = File.Create("FormControlMapPdfFormFieldBasicUsage.pdf") ' Create a new Workbook Dim workbook As New Workbook Dim ws As IWorksheet = workbook.Worksheets("Sheet1") ws.Range("$B$2:$C$2").Value = New Object(,) { {"Excel Form Control", "Mapped to form field"} } ws.Range("$B$4").Value = "Dropdown (Combo box) " ws.Range("$B$6").Value = "List box" ws.Range("$B$11").Value = "Option button" ws.Range("$B$14").Value = "Check box" ws.Range("$B$2:$C$2").Interior.ThemeColor = ThemeColor.Light2 ws.Range("$B$4").VerticalAlignment = VerticalAlignment.Center ws.Range("$B$14").VerticalAlignment = VerticalAlignment.Center ws.Range("$4:$4,$14:$14").RowHeight = 18.6R ws.Range("$11:$11").RowHeight = 15.6R ws.Range("$12:$12").RowHeight = 26.4R ws.Range("$B:$B").ColumnWidthInPixel = 162.0R ws.Range("$C:$C").ColumnWidthInPixel = 214.0R Dim ctl1 = ws.Controls.AddDropDown(177.3, 45.6, 141, 16.79) With ctl1.Items .Add(New DropDownItem("Item 1")) .Add(New DropDownItem("Item 2")) .Add(New DropDownItem("Item 3")) End With ctl1.SelectedIndex = 0 Dim ctl2 = ws.Controls.AddListBox(177.9, 80.39, 140.4, 55.8) With ctl2.Items .Add(New ListBoxItem("Item 1")) .Add(New ListBoxItem("Item 2")) .Add(New ListBoxItem("Item 3")) End With Dim ctl3 = ws.Controls.AddOptionButton(176.7, 152.4, 71.4, 17.39) ctl3.Text = "Option Button 1" Dim ctl4 = ws.Controls.AddOptionButton(177.3, 175.2, 71.39, 16.8) ctl4.Text = "Option Button 2" Dim ctl5 = ws.Controls.AddCheckBox(177.9, 211.79, 58.19, 16.8) ctl5.Text = "Check Box 1" workbook.Save(outputStream, New PdfSaveOptions With {.FormFields = True}) ' close the pdf stream outputStream.Close()