This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.vb
70 lines (61 loc) · 3.06 KB
/
Program.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Imports DevExpress.Snap
Imports DevExpress.Snap.Core.API
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Imports SnapServerGettingStarted.NWindDataSetTableAdapters
Imports System
Imports System.Data.SqlClient
Namespace SnapServerGettingStarted
Friend Class Program
Shared Sub Main(ByVal args() As String)
' #Region "#Main"
Dim server As New SnapDocumentServer()
Dim document As SnapDocument = server.Document
Dim datasource As Object = GetDataSource()
document.DataSource = datasource
Console.Write("Generating Document... ")
GenerateLayout(document)
Console.WriteLine("Ok!")
Console.Write("Press any key...")
Console.ReadKey()
System.Diagnostics.Process.Start("SnapDocumentServerTest.rtf")
' #End Region ' #Main
End Sub
#Region "#GenerateLayout"
Private Shared Sub GenerateLayout(ByVal document As SnapDocument)
' Add a Snap list to the document.
Dim list As SnapList = document.CreateSnList(document.Range.End, "List")
list.BeginUpdate()
list.EditorRowLimit = 100500
' Add a header to the Snap list.
Dim listHeader As SnapDocument = list.ListHeader
Dim listHeaderTable As Table = listHeader.Tables.Create(listHeader.Range.End, 1, 3)
Dim listHeaderCells As TableCellCollection = listHeaderTable.FirstRow.Cells
listHeader.InsertText(listHeaderCells(0).ContentRange.End, "Product Name")
listHeader.InsertText(listHeaderCells(1).ContentRange.End, "Units in Stock")
listHeader.InsertText(listHeaderCells(2).ContentRange.End, "Unit Price")
'Create the row template and fill it with data
Dim listRow As SnapDocument = list.RowTemplate
Dim listRowTable As Table = listRow.Tables.Create(listRow.Range.End, 1, 3)
Dim listRowCells As TableCellCollection = listRowTable.FirstRow.Cells
listRow.CreateSnText(listRowCells(0).ContentRange.End, "ProductName")
listRow.CreateSnText(listRowCells(1).ContentRange.End, "UnitsInStock")
listRow.CreateSnText(listRowCells(2).ContentRange.End, "UnitPrice \$ $0.00")
list.EndUpdate()
list.Field.Update()
document.ExportDocument("SnapDocumentServerTest.rtf", DocumentFormat.Rtf)
End Sub
#End Region ' #GenerateLayout
#Region "#DataSource"
Private Shared Function GetDataSource() As Object
Dim dataSource As New NWindDataSet()
Dim connection = New SqlConnection()
connection.ConnectionString = My.Settings.Default.NWindConnectionString
Dim products As New ProductsTableAdapter()
products.Connection = connection
products.Fill(dataSource.Products)
Return dataSource.Products
End Function
#End Region ' #DataSource
End Class
End Namespace