| |
 |
Customer Labels - Aspose.Cells
|
 |
This online demo illustrates
how to create a well formatted Customer Labels report using
Aspose.Cells for .NET.
Aspose.Cells component gives
you the agility to report your data in a variety of ways. Aspose.Cells component
is fully functional for creating all types of reports. You may customize the size
and appearance of everything on a report. You can display the information the way
you want to see it.
The demo generates a printed
report displaying customers' company names and addresses on 3-up labels. ADO.NET is used to retrieve the data from the Customers table
of Northwind database, to generate the report. You can either open the resultant excel file into MS Excel
or save directly to your disk to check the results.
Click Process to see how example
Prints customers' company names and addresses on 3-up labels.
| 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="VB" AutoEventWireup="true" CodeBehind="customer-labels-form.aspx.vb" Inherits="Aspose.Cells.Demos.VisualBasic.CustomerLabelsForm"
MasterPageFile="~/tpl/Demo.Master" Title="Customer Labels - Apose.Cells Demos"%>
<asp:Content ID="Content" 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">Customer Labels - 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="MsoNormal">
<font face="Arial"><span style="color: black"><font size="2">This online demo illustrates
how to create a well formatted Customer Labels report </font></span></font><font
size="2"><span style="font-family: Arial">using </span><font face="Arial"><a href="http://www.aspose.com/categories/.net-components/aspose.cells-for-.net/default.aspx">
Aspose.Cells</a> for .NET</font><span style="font-family: Arial">.</span></font><font
face="Arial" size="2"> </font>
</p>
<p class="MsoNormal">
<font face="Arial" size="2"><span style="color: black">Aspose.Cells component gives
you the agility to report your data in a variety of ways. Aspose.Cells component
is fully functional for creating all types of reports. You may customize the size
and appearance of everything on a report. You can display the information the way
you want to see it. </span></font>
</p>
<p class="MsoNormal">
<font face="Arial" size="2"><span style="color: black">The demo generates a printed
report displaying </span>customers' company names and addresses on 3-up labels.<span
style="color: black"> ADO.NET is used to retrieve the data from the Customers table
of Northwind database, to generate the report. </span>You can either open the resultant excel file into MS Excel
or save directly to your disk to check the results.</font></p>
<p class="componentDescriptionTxt">
Click <b>Process </b> to see how example
Prints customers' company names and addresses on 3-up labels. </SPAN></p>
<asp:Button ID="btnExecute" runat="server" Text="Process" OnClick="btnExecute_Click"/>
</asp:Content>
|
| Visual Basic |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
Imports Aspose.Cells
Public Class CustomerLabelsForm
Inherits System.Web.UI.Page
Protected Sub btnExecute_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim workbook As Workbook
Dim path As String = MapPath(".")
path = path.Substring(0, path.LastIndexOf("\"))
Dim param As String = "CustomerLabels"
'Create Customer Labels
Dim CustomerLabels As CustomerLabels = New CustomerLabels(path)
workbook = CustomerLabels.CreateCustomerLabels()
workbook.Save(param + ".xls", SaveType.OpenInExcel, FileFormatType.Excel97To2003, Me.Response)
' End response to avoid unneeded HTML after XLS
Response.End()
End Sub
End Class
|
| Visual Basic |
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
|
Public Class CustomerLabels
Inherits DbBase
Public Sub New(ByVal path As String)
MyBase.New(path)
End Sub
Public Function CreateCustomerLabels() As Workbook
DBInit()
Dim designerFile As String = path + "\\Designer\\Northwind.xls"
Dim workbook As workbook = New workbook()
workbook.Open(designerFile)
Me.oleDbSelectCommand1.CommandText = "SELECT CompanyName, Address, City, Region, PostalCode, Country, CustomerID FROM " + _
"Customers ORDER BY Country, Region"
Me.oleDbDataAdapter1.Fill(Me.dataTable1)
Dim sheet As Worksheet = workbook.Worksheets("Sheet4")
sheet.Name = "Customer Labels"
Dim cells As cells = sheet.Cells
Dim row As Integer = 0
Dim column As Byte = 0
Dim i As Integer
For i = 0 To Me.dataTable1.Rows.Count - 1
Dim remainder As Integer = Decimal.Remainder(i, 3)
Dim cell As cell
Select Case remainder
Case 0
column = 0
Case 1
column = 3
Case 2
column = 6
End Select
cell = cells(row, column)
cell.PutValue(CType(Me.dataTable1.Rows(i)("CompanyName"), String))
cell = cells(row + 1, column)
cell.PutValue(CType(Me.dataTable1.Rows(i)("Address"), String))
cell = cells(row + 2, column)
Dim contact As String = ""
If Not Me.dataTable1.Rows(i)("City") Is DBNull.Value Then
contact += CType(Me.dataTable1.Rows(i)("City") + " ", String)
End If
If Not Me.dataTable1.Rows(i)("Region") Is DBNull.Value Then
contact += CType(Me.dataTable1.Rows(i)("Region") + " ", String)
End If
If Not Me.dataTable1.Rows(i)("PostalCode") Is DBNull.Value Then
contact += CType(Me.dataTable1.Rows(i)("PostalCode"), String)
End If
cell.PutValue(contact)
cell = cells(row + 3, column)
cell.PutValue(CType(Me.dataTable1.Rows(i)("Country"), String))
If remainder = 2 Then
row += 5
End If
Next
For i = 0 To workbook.Worksheets.Count - 1
If (i >= workbook.Worksheets.Count) Then
Exit For
End If
sheet = workbook.Worksheets(i)
If sheet.Name <> "Customer Labels" Then
workbook.Worksheets.RemoveAt(i)
i = i - 1
End If
Next
Return workbook
End Function
End Class
|
|
|
|