| |
 |
Sales Totals by Amount - Aspose.Cells
|
 |
This online demo illustrates
how to create a well formatted Sales Totals by Amount 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 the report
listing sales in descending order by
amount. It Prints top 10 customers on first page and prints page total in page footer.
ADO.NET is used to retrieve the
data from the Orders and 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 sales in descending order by amount, prints top 10 customers on first page,
prints page total in page footer.
| 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
46
47
48
49
50
51
52
53
54
55
|
<%@ Page Language="VB" AutoEventWireup="true" Codebehind="sales-totals-form.aspx.vb"
Inherits="Aspose.Cells.Demos.VisualBasic.SalesTotalsForm" MasterPageFile="~/tpl/Demo.Master"
Title="Sales Totals by Amount - 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">
<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">Sales Totals by Amount - 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 Sales Totals by Amount 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">
<span style="color: black"><font face="Arial" size="2">The demo generates the report
listing </font></span><font size="2"><font face="Arial">sales in descending order by
amount. It Prints top 10 customers on first page and prints page total in page footer.
</font><span style="color: black"><font face="Arial">ADO.NET is used to retrieve the
data from the Orders and Customers table of Northwind database, to generate the
report. </font></span></font><font face="Arial" size="2">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 sales in descending order by amount, prints top 10 customers on first page,
prints page total in page footer.
<br/>
</SPAN></p>
<p class="componentDescriptionTxt">
<asp:Button ID="btnExecute" runat="server" Text="Process" OnClick="btnExecute_Click" /> </p>
</asp:Content>
|
| Visual Basic |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
Imports Aspose.Cells
Public Class SalesTotalsForm
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 = "SalesTotals"
'Create Sales Totals
Dim SalesTotals As SalesTotals = New SalesTotals(path)
workbook = SalesTotals.CreateSalesTotals()
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
|
Public Class SalesTotals
Inherits DbBase
Public Sub New(ByVal path As String)
MyBase.New(path)
End Sub
Public Function CreateSalesTotals() As Workbook
DBInit()
Dim designerFile As String = path + "\\Designer\\Northwind.xls"
Dim workbook As workbook = New workbook()
workbook.Open(designerFile)
Me.oleDbSelectCommand1.CommandText = "SELECT [Order Subtotals].Subtotal, [Order Subtotals].OrderID, " + _
" Customers.CompanyName, Customers.CustomerID FROM Customers " + _
" INNER JOIN ([Order Subtotals] INNER JOIN Orders ON [Order Subtotals].OrderID = Orders.OrderID) " + _
" ON Customers.CustomerID = Orders.CustomerID " + _
" WHERE (Orders.ShippedDate BETWEEN #1/1/1995# AND #12/31/1995#) AND ([Order Subtotals].Subtotal > 2500) " + _
" ORDER BY [Order Subtotals].Subtotal DESC"
Me.oleDbDataAdapter1.Fill(Me.dataTable1)
Dim sheet As Worksheet = workbook.Worksheets("Sheet12")
sheet.Name = "Sales Totals"
Dim cells As cells = sheet.Cells
cells.ImportDataTable(Me.dataTable1, False, 3, 1, Me.dataTable1.Rows.Count, 3)
Dim totalSum As Decimal = 0.0
Dim i As Integer
For i = 0 To Me.dataTable1.Rows.Count - 1
totalSum += CType(Me.dataTable1.Rows(i)("Subtotal"), Decimal)
cells(3 + i, 5).PutValue(i + 1)
Next
cells(3 + Me.dataTable1.Rows.Count, 0).PutValue("Total:")
Dim style As style = workbook.Styles(workbook.Styles.Add())
style.Font.IsBold = True
cells(3 + Me.dataTable1.Rows.Count, 0).Style = style
cells(3 + Me.dataTable1.Rows.Count, 1).PutValue(CType(totalSum, Double))
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 <> "Sales Totals" Then
workbook.Worksheets.RemoveAt(i)
i = i - 1
End If
Next
Return workbook
End Function
End Class
|
|
|
|