| |
 |
Adding Radio Button - Aspose.Cells
|
 |
This demo shows how to add radio button control in your
worksheet using
Aspose.Cells for .NET.
A Radio Button or an option button is
a control made of a round box O. The user makes his or her decision by selecting
or clicking the round box. Actually, a radio button is usually, if not always accompanied
by other radio buttons. Such radio buttons appear and behave as a group. The user
decides which button is valid by selecting only one of them. When the user clicks
one button, its round box fills with a (big) dot. When one button in the group is
selected, the other round buttons of the (same) group are empty. The demo creates an excel file. Then by using simple Aspose.Cells
APIs it adds three radio buttons as a group and apply different format setting to
them.
Click Process to see how example adds RadioButtons in the workbook with different formatting options.
You can either open the resulting excel file into MS Excel
or save directly to your disk.
| ASP.NET |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<%@ Page Language="C#" MasterPageFile="~/tpl/Demo.Master" AutoEventWireup="true"
CodeBehind="adding-radiobutton.aspx.cs" Inherits="Workbooks_Controls_AddRadioButton" Title="Adding RadioButton - Aspose.Cells Demos" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<p class="componentDescriptionTxt">
<span style="font-size: 10pt; font-family: Arial"></span> </p>
<p class="componentDescriptionTxt">
<span style="font-size: 10pt; font-family: Arial"></span>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td valign="top" width="19">
<img alt="" height="41" src="/Common/images/heading_lft.jpg" width="19" /></td>
<td class="demos-heading-bg" width="100%">
<h2 class="demos-heading-bg">
<font face="Arial" size="4">Adding Radio Button - Aspose.Cells</font></h2>
</td>
<td valign="top" width="19">
<img alt="" height="41" src="/Common/images/heading_rt.jpg" width="19" /></td>
</tr>
</table>
</p>
<p class="componentDescriptionTxt">
<font face="Arial" size="2">This demo shows how to add radio button control in your
worksheet using <a href="http://www.aspose.com/categories/.net-components/aspose.cells-for-.net/default.aspx">
Aspose.Cells</a> for .NET.</font></p>
<p style="margin: 5pt 0pt">
<span style="font-family: Arial"><font size="2">A Radio Button or an option button is
a control made of a round box O. The user makes his or her decision by selecting
or clicking the round box. Actually, a radio button is usually, if not always accompanied
by other radio buttons. Such radio buttons appear and behave as a group. The user
decides which button is valid by selecting only one of them. When the user clicks
one button, its round box fills with a (big) dot. When one button in the group is
selected, the other round buttons of the (same) group are empty.</font></span><font
face="Arial" size="2"> The demo creates an excel file. Then by using simple Aspose.Cells
APIs it adds three radio buttons as a group and apply different format setting to
them.</font></SPAN></p>
<p style="margin: 5pt 0pt">
<span style="font-size: 10pt; font-family: Arial"><font face="Arial" size="2"></font>
Click <b>Process </b> to see how example adds RadioButtons in the workbook with different formatting options.
You can either open the resulting excel file into MS Excel
or save directly to your disk.</span></p>
<p>
<asp:Button ID="btnExecute" runat="server" Text="Process" OnClick="btnExecute_Click" /> </p>
</asp:Content>
|
| C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Aspose.Cells;
using System.Drawing;
using Aspose.Cells.Drawing;
public partial class Workbooks_Controls_AddRadioButton : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList ddlFileVersion;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnExecute_Click(object sender, EventArgs e)
{
//Call Method to create report
CreateStaticReport();
}
protected void CreateStaticReport()
{
//Instantiate a new Workbook.
Workbook excelbook = new Workbook();
//Insert a value in C2 cell
excelbook.Worksheets[0].Cells["C2"].PutValue("Age Groups");
//Get style from C2 cell
Aspose.Cells.Style style = excelbook.Worksheets[0].Cells["C2"].GetStyle();
//Set the font text bold.
style.Font.IsBold = true;
//Set style to C2 Cell
excelbook.Worksheets[0].Cells["C2"].SetStyle(style);
//Add a radio button to the first sheet.
Aspose.Cells.Drawing.RadioButton radio1 = excelbook.Worksheets[0].Shapes.AddRadioButton(3, 0, 2, 0, 30, 110);
//Set its text string.
radio1.Text = "20-29";
//Set A1 cell as a linked cell for the radio button.
radio1.LinkedCell = "A1";
//Make the radio button 3-D.
radio1.Shadow = true;
//Set the foreground color of the radio button.
radio1.FillFormat.ForeColor = Color.LightGreen;
// set the line style of the radio button.
radio1.LineFormat.Style = MsoLineStyle.ThickThin;
//Set the weight of the radio button.
radio1.LineFormat.Weight = 4;
//Set the line color of the radio button.
radio1.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the radio button.
radio1.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Make the line format visible.
radio1.LineFormat.IsVisible = true;
//Make the fill format visible.
radio1.FillFormat.IsVisible = true;
//Add another radio button to the first sheet.
Aspose.Cells.Drawing.RadioButton radio2 = excelbook.Worksheets[0].Shapes.AddRadioButton(6, 0, 2, 0, 30, 110);
//Set its text string.
radio2.Text = "30-39";
//Set A1 cell as a linked cell for the radio button.
radio2.LinkedCell = "A1";
//Make the radio button 3-D.
radio2.Shadow = true;
//Set the foreground color of the radio button.
radio2.FillFormat.ForeColor = Color.LightGreen;
// set the line style of the radio button.
radio2.LineFormat.Style = MsoLineStyle.ThickThin;
//Set the weight of the radio button.
radio2.LineFormat.Weight = 4;
//Set the line color of the radio button.
radio2.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the radio button.
radio2.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Make the line format visible.
radio2.LineFormat.IsVisible = true;
//Make the fill format visible.
radio2.FillFormat.IsVisible = true;
//Add another radio button to the first sheet.
Aspose.Cells.Drawing.RadioButton radio3 = excelbook.Worksheets[0].Shapes.AddRadioButton(9, 0, 2, 0, 30, 110);
//Set its text string.
radio3.Text = "40-49";
//Set A1 cell as a linked cell for the radio button.
radio3.LinkedCell = "A1";
//Make the radio button 3-D.
radio3.Shadow = true;
//Set the foreground color of the radio button.
radio3.FillFormat.ForeColor = Color.LightGreen;
// set the line style of the radio button.
radio3.LineFormat.Style = MsoLineStyle.ThickThin;
//Set the weight of the radio button.
radio3.LineFormat.Weight = 4;
//Set the line color of the radio button.
radio3.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the radio button.
radio3.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Make the line format visible.
radio3.LineFormat.IsVisible = true;
//Make the fill format visible.
radio3.FillFormat.IsVisible = true;
if (ddlFileVersion.SelectedItem.Value == "XLS")
{
////Save file and send to client browser using selected format
excelbook.Save(HttpContext.Current.Response, "ComboBox.xls", ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003));
}
else
{
excelbook.Save(HttpContext.Current.Response, "ComboBox.xlsx", ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsx));
}
// End response to avoid unneeded html after xls
System.Web.HttpContext.Current.Response.End();
}
}
|
|
|
|