-
Notifications
You must be signed in to change notification settings - Fork 2
/
Default.aspx.vb
54 lines (46 loc) · 1.76 KB
/
Default.aspx.vb
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
Imports Microsoft.VisualBasic
Imports System
Imports System.IO
Imports DevExpress.XtraCharts
Imports DevExpress.XtraCharts.Native
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraPrintingLinks
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If (Not IsPostBack) Then
Tree.DataBind()
Tree.ExpandToLevel(2)
End If
Chart.SeriesDataMember = "CategoryName"
Chart.SeriesTemplate.ArgumentDataMember = "ProductSales"
Chart.SeriesTemplate.ValueDataMembers.AddRange(New String() { "ProductSales" })
Chart.SeriesTemplate.View = New StackedBarSeriesView()
End Sub
Protected Sub ExportButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim ps As New PrintingSystemBase()
Dim link1 As New PrintableComponentLinkBase(ps)
link1.Component = GridExporter
Dim link2 As New PrintableComponentLinkBase(ps)
link2.Component = TreeListExporter
Dim link3 As New PrintableComponentLinkBase(ps)
Chart.DataBind()
link3.Component = (CType(Chart, IChartContainer)).Chart
Dim compositeLink As New CompositeLinkBase(ps)
compositeLink.Links.AddRange(New Object() { link1, link2, link3 })
compositeLink.CreatePageForEachLink()
Using stream As New MemoryStream()
Dim options As New XlsxExportOptions()
options.ExportMode = XlsxExportMode.SingleFilePageByPage
compositeLink.PrintingSystemBase.ExportToXlsx(stream, options)
Response.Clear()
Response.Buffer = False
Response.AppendHeader("Content-Type", "application/xlsx")
Response.AppendHeader("Content-Transfer-Encoding", "binary")
Response.AppendHeader("Content-Disposition", "attachment; filename=test.xlsx")
Response.BinaryWrite(stream.ToArray())
Response.End()
End Using
ps.Dispose()
End Sub
End Class