Table of Contents

HTML (VB.Net / netframework)

Note

This demo is available in your FlexCel installation at <FlexCel Install Folder>\samples\vb\VS2022\netframework\20.Reports\83.HTML and also at https:​//​github.​com/​tmssoftware/​TMS-​FlexCel.​NET-​demos/​tree/​master/​vb/​VS2022/​netframework/​Modules/​20.​Reports/​83.​HTML

Overview

A demo that shows how to use HTML formatted strings directly on FlexCel. On this example we used to connect to Yahoo Travel web service, and format the results into an Excel or pdf sheet. As Yahoo Travel doesn't exist anymore, some sample data is included to work offline without connecting.

Concepts

  • FlexCel supports a light subset of HTML commands, like <b>, <br>, and the escaped characters like &. But this should be enough to for having rich format inside cells.

  • Any HTML tag that FlexCel cannot parse will be ignored.

  • Note how the word "London" is in bold in titles like "London and Paris". This is because the HTML returned contained those tags.

  • You can allow HTML in a FlexCelReport in two ways:

    1. You can enable it globally by setting FlexCelReport.HTMLMode = true, and disable it where not needed with the <#HTML(false)> tag. This is not normally recommended, since when in HTML mode all strings have to be html strings, where for example two spaces mean only one, and carriage returns are created with <br> tags.

    2. You can enable it on a cell by cell basis, by using the <#HTML(true)> tag. This is the approach we use here.

  • How to set Intelligent Page Breaks. FlexCel will add page breaks so all entries are kept together when printing or exporting to pdf.

  • You can also set an hyperlink in an image. In this case, we wrote an hyperlink in the image pointing to the URL in the database. This link is also exported to pdf.

Files

AssemblyInfo.vb

Imports System.Reflection
Imports System.Runtime.CompilerServices

'
' General Information about an assembly is controlled through the following 
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
'
<Assembly: AssemblyTitle("")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyConfiguration("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("")>
<Assembly: AssemblyCopyright("(c) 2002 - 2014 TMS Software")>
<Assembly: AssemblyTrademark("")>
<Assembly: AssemblyCulture("")>

'
' Version information for an assembly consists of the following four values:
'
'      Major Version
'      Minor Version 
'      Build Number
'      Revision
'
' You can specify all the values or you can default the Revision and Build Numbers 
' by using the '*' as shown below:

<Assembly: AssemblyVersion("6.2.1.0")>

'
' In order to sign your assembly you must specify a key to use. Refer to the 
' Microsoft .NET Framework documentation for more information on assembly signing.
'
' Use the attributes below to control which key is used for signing. 
'
' Notes: 
'   (*) If no key is specified, the assembly is not signed.
'   (*) KeyName refers to a key that has been installed in the Crypto Service
'       Provider (CSP) on your machine. KeyFile refers to a file which contains
'       a key.
'   (*) If the KeyFile and the KeyName values are both specified, the 
'       following processing occurs:
'       (1) If the KeyName can be found in the CSP, that key is used.
'       (2) If the KeyName does not exist and the KeyFile does exist, the key 
'           in the KeyFile is installed into the CSP and used.
'   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
'       When specifying the KeyFile, the location of the KeyFile should be
'       relative to the project output directory which is
'       %Project Directory%\obj\<configuration>. For example, if your KeyFile is
'       located in the project directory, you would specify the AssemblyKeyFile 
'       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
'   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
'       documentation for more information on this.
'
<Assembly: AssemblyDelaySign(False)>
<Assembly: AssemblyKeyFile("")>
<Assembly: AssemblyKeyName("")>

Form1.Designer.vb

Imports System.Collections
Imports System.ComponentModel
Imports System.IO
Imports System.Reflection
Imports System.Xml
Imports System.Net
Imports System.Threading
Imports System.Globalization
Imports FlexCel.Core
Imports FlexCel.XlsAdapter
Imports FlexCel.Report
Imports FlexCel.Render
Namespace HTML
	Partial Public Class mainForm
		Inherits System.Windows.Forms.Form

		''' <summary>
		''' Required designer variable.
		''' </summary>
		Private components As System.ComponentModel.Container = Nothing

		''' <summary>
		''' Clean up any resources being used.
		''' </summary>
		Protected Overrides Sub Dispose(ByVal disposing As Boolean)
			If disposing Then
				If components IsNot Nothing Then
					components.Dispose()
				End If
			End If
			MyBase.Dispose(disposing)
		End Sub

		#Region "Windows Form Designer generated code"
		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()
			Me.btnExportXls = New System.Windows.Forms.Button()
			Me.saveFileDialogXls = New System.Windows.Forms.SaveFileDialog()
			Me.btnCancel = New System.Windows.Forms.Button()
			Me.cbOffline = New System.Windows.Forms.CheckBox()
			Me.btnExportPdf = New System.Windows.Forms.Button()
			Me.saveFileDialogPdf = New System.Windows.Forms.SaveFileDialog()
			Me.edCity = New System.Windows.Forms.TextBox()
			Me.labelCity = New System.Windows.Forms.Label()
			Me.label1 = New System.Windows.Forms.Label()
			Me.linkLabel1 = New System.Windows.Forms.LinkLabel()
			Me.panel1 = New System.Windows.Forms.Panel()
			Me.label2 = New System.Windows.Forms.Label()
			Me.panel1.SuspendLayout()
			Me.SuspendLayout()
			' 
			' btnExportXls
			' 
			Me.btnExportXls.Anchor = (CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
			Me.btnExportXls.BackColor = System.Drawing.Color.Green
			Me.btnExportXls.ForeColor = System.Drawing.Color.White
			Me.btnExportXls.Location = New System.Drawing.Point(16, 258)
			Me.btnExportXls.Name = "btnExportXls"
			Me.btnExportXls.Size = New System.Drawing.Size(112, 24)
			Me.btnExportXls.TabIndex = 0
			Me.btnExportXls.Text = "Export to Excel"
			Me.btnExportXls.UseVisualStyleBackColor = False
'			Me.btnExportXls.Click += New System.EventHandler(Me.btnExportXls_Click)
			' 
			' saveFileDialogXls
			' 
			Me.saveFileDialogXls.Filter = "Excel Files|*.xls;*.xlsx;*.xlsm|Excel 97/2003|*.xls|Excel 2007|*.xlsx;*.xlsm|All " & "files|*.*"
			Me.saveFileDialogXls.RestoreDirectory = True
			' 
			' btnCancel
			' 
			Me.btnCancel.Anchor = (CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
			Me.btnCancel.BackColor = System.Drawing.Color.FromArgb((CInt((CByte(192)))), (CInt((CByte(0)))), (CInt((CByte(0)))))
			Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
			Me.btnCancel.ForeColor = System.Drawing.Color.White
			Me.btnCancel.Location = New System.Drawing.Point(272, 258)
			Me.btnCancel.Name = "btnCancel"
			Me.btnCancel.Size = New System.Drawing.Size(112, 24)
			Me.btnCancel.TabIndex = 3
			Me.btnCancel.Text = "Cancel"
			Me.btnCancel.UseVisualStyleBackColor = False
'			Me.btnCancel.Click += New System.EventHandler(Me.btnCancel_Click)
			' 
			' cbOffline
			' 
			Me.cbOffline.Checked = True
			Me.cbOffline.CheckState = System.Windows.Forms.CheckState.Checked
			Me.cbOffline.Location = New System.Drawing.Point(13, 200)
			Me.cbOffline.Name = "cbOffline"
			Me.cbOffline.Size = New System.Drawing.Size(352, 24)
			Me.cbOffline.TabIndex = 10
			Me.cbOffline.Text = "Use offline data. (do not actually connect to the web service)"
			' 
			' btnExportPdf
			' 
			Me.btnExportPdf.Anchor = (CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
			Me.btnExportPdf.BackColor = System.Drawing.Color.SteelBlue
			Me.btnExportPdf.ForeColor = System.Drawing.Color.White
			Me.btnExportPdf.Location = New System.Drawing.Point(144, 258)
			Me.btnExportPdf.Name = "btnExportPdf"
			Me.btnExportPdf.Size = New System.Drawing.Size(112, 24)
			Me.btnExportPdf.TabIndex = 11
			Me.btnExportPdf.Text = "Export to Pdf"
			Me.btnExportPdf.UseVisualStyleBackColor = False
'			Me.btnExportPdf.Click += New System.EventHandler(Me.btnExportPdf_Click)
			' 
			' saveFileDialogPdf
			' 
			Me.saveFileDialogPdf.Filter = "Pdf Files|*.pdf"
			Me.saveFileDialogPdf.RestoreDirectory = True
			' 
			' edCity
			' 
			Me.edCity.Location = New System.Drawing.Point(157, 160)
			Me.edCity.Name = "edCity"
			Me.edCity.Size = New System.Drawing.Size(208, 20)
			Me.edCity.TabIndex = 12
			Me.edCity.Text = "london"
			' 
			' labelCity
			' 
			Me.labelCity.Location = New System.Drawing.Point(5, 152)
			Me.labelCity.Name = "labelCity"
			Me.labelCity.Size = New System.Drawing.Size(144, 40)
			Me.labelCity.TabIndex = 13
			Me.labelCity.Text = "City Name: (try things like tokio, sydney, new york, madrid, rio de janeiro)"
			' 
			' label1
			' 
			Me.label1.Font = New System.Drawing.Font("Times New Roman", 10.25F, System.Drawing.FontStyle.Italic)
			Me.label1.Location = New System.Drawing.Point(13, 88)
			Me.label1.Name = "label1"
			Me.label1.Size = New System.Drawing.Size(352, 32)
			Me.label1.TabIndex = 14
			Me.label1.Text = "This application uses Yahoo Travel APIs to load demo trips and export them to Exc" & "el. For more information, visit:"
			' 
			' linkLabel1
			' 
			Me.linkLabel1.Location = New System.Drawing.Point(13, 128)
			Me.linkLabel1.Name = "linkLabel1"
			Me.linkLabel1.Size = New System.Drawing.Size(320, 16)
			Me.linkLabel1.TabIndex = 15
			Me.linkLabel1.TabStop = True
			Me.linkLabel1.Text = "http://developer.yahoo.com/travel/"
'			Me.linkLabel1.LinkClicked += New System.Windows.Forms.LinkLabelLinkClickedEventHandler(Me.linkLabel1_LinkClicked)
			' 
			' panel1
			' 
			Me.panel1.BackColor = System.Drawing.Color.LightGoldenrodYellow
			Me.panel1.Controls.Add(Me.label2)
			Me.panel1.Dock = System.Windows.Forms.DockStyle.Top
			Me.panel1.Location = New System.Drawing.Point(0, 0)
			Me.panel1.Name = "panel1"
			Me.panel1.Size = New System.Drawing.Size(416, 69)
			Me.panel1.TabIndex = 16
			' 
			' label2
			' 
			Me.label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (CByte(0)))
			Me.label2.Location = New System.Drawing.Point(12, 9)
			Me.label2.Name = "label2"
			Me.label2.Size = New System.Drawing.Size(392, 49)
			Me.label2.TabIndex = 0
			Me.label2.Text = "IMPORTANT: Yahoo has discontinued this service, so this demo will only work with " & "offline data. As the online functionality isn't essential to this demo, we have " & "decided to keep it."
			' 
			' mainForm
			' 
			Me.AutoScaleDimensions = New System.Drawing.SizeF(6F, 13F)
			Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
			Me.ClientSize = New System.Drawing.Size(416, 292)
			Me.Controls.Add(Me.panel1)
			Me.Controls.Add(Me.linkLabel1)
			Me.Controls.Add(Me.label1)
			Me.Controls.Add(Me.labelCity)
			Me.Controls.Add(Me.edCity)
			Me.Controls.Add(Me.btnExportPdf)
			Me.Controls.Add(Me.cbOffline)
			Me.Controls.Add(Me.btnCancel)
			Me.Controls.Add(Me.btnExportXls)
			Me.Name = "mainForm"
			Me.Text = "Using HTML formatted text with FlexCel"
			Me.panel1.ResumeLayout(False)
			Me.ResumeLayout(False)
			Me.PerformLayout()

		End Sub
		#End Region
		Private WithEvents btnCancel As System.Windows.Forms.Button
		Private cbOffline As System.Windows.Forms.CheckBox
		Private WithEvents btnExportXls As System.Windows.Forms.Button
		Private WithEvents btnExportPdf As System.Windows.Forms.Button
		Private saveFileDialogXls As System.Windows.Forms.SaveFileDialog
		Private saveFileDialogPdf As System.Windows.Forms.SaveFileDialog
		Private edCity As System.Windows.Forms.TextBox
		Private labelCity As System.Windows.Forms.Label
		Private label1 As System.Windows.Forms.Label
		Private WithEvents linkLabel1 As System.Windows.Forms.LinkLabel
		Private panel1 As Panel
		Private label2 As Label
	End Class
End Namespace


Form1.vb

Imports System.Collections
Imports System.ComponentModel
Imports System.IO
Imports System.Reflection
Imports System.Xml
Imports System.Net
Imports System.Threading
Imports System.Globalization

Imports FlexCel.Core
Imports FlexCel.XlsAdapter
Imports FlexCel.Report
Imports FlexCel.Render

Namespace HTML
	''' <summary>
	''' Shows the limited HTML support.
	''' </summary>
	Partial Public Class mainForm
		Inherits System.Windows.Forms.Form

		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub Export(ByVal SaveDialog As SaveFileDialog, ByVal ToPdf As Boolean)
			Using reportStart As New FlexCelReport(True)

				If cbOffline.Checked AndAlso edCity.Text <> "london" Then
					MessageBox.Show("Offline mode is selected, so we will show the data of london. The actual city you wrote will not be used unless you select online mode.", "Warning")
				End If
				Try
					Dim DataPath As String = Path.Combine(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), ".."), "..") & Path.DirectorySeparatorChar
					Dim OfflineDataPath As String = Path.Combine(DataPath, "OfflineData") & Path.DirectorySeparatorChar

					'We will use a thread to connect, to avoid "freezing" the GUI
					Dim MyWebConnect As New WebConnectThread(reportStart, edCity.Text, OfflineDataPath, cbOffline.Checked)
					Dim WebConnect As New Thread(New ThreadStart(AddressOf MyWebConnect.LoadData))
					WebConnect.Start()
					Using Pg As New ProgressDialog()
						Pg.ShowProgress(WebConnect)
						If MyWebConnect IsNot Nothing AndAlso MyWebConnect.MainException IsNot Nothing Then
							Throw MyWebConnect.MainException
						End If
					End Using


					If SaveDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
						If ToPdf Then
							Dim xls As New XlsFile()
							xls.Open(DataPath & "HTML.template.xls")
							reportStart.Run(xls)
							Using PdfExport As New FlexCelPdfExport(xls, True)
								PdfExport.Export(SaveDialog.FileName)
							End Using
						Else
							reportStart.Run(DataPath & "HTML.template.xls", SaveDialog.FileName)
						End If

						If MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) = System.Windows.Forms.DialogResult.Yes Then
							Process.Start(SaveDialog.FileName)
						End If
					End If
				Catch ex As Exception
					MessageBox.Show(ex.Message)
				End Try
			End Using
		End Sub

		Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
			Close()
		End Sub

		Private Sub btnExportPdf_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportPdf.Click
			Export(saveFileDialogPdf, True)
		End Sub

		Private Sub btnExportXls_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportXls.Click
			Export(saveFileDialogXls, False)
		End Sub

		Private Sub linkLabel1_LinkClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles linkLabel1.LinkClicked
			System.Diagnostics.Process.Start((TryCast(sender, LinkLabel)).Text)
		End Sub
	End Class

	Friend Class WebConnectThread
		Private CityName As String
		Private DataPath As String
		Private UseOfflineData As Boolean
		Private ReportStart As FlexCelReport
		Private FMainException As Exception

		Public Sub New(ByVal aReportStart As FlexCelReport, ByVal aCityName As String, ByVal aDataPath As String, ByVal aUseOfflineData As Boolean)
			CityName = aCityName
			DataPath = aDataPath
			UseOfflineData = aUseOfflineData
			ReportStart = aReportStart
		End Sub


		''' <summary>
		''' This is the method we will call form a thread. It catches any internal exception.
		''' </summary>
		Public Sub LoadData()
			Try
				LoadData(ReportStart, CityName, DataPath, UseOfflineData)
			Catch ex As Exception
				FMainException = ex
			End Try

		End Sub

		Public Shared Sub LoadData(ByVal reportStart As FlexCelReport, ByVal CityName As String, ByVal DataPath As String, ByVal UseOfflineData As Boolean)
			reportStart.SetValue("Date", Date.Now)
			Dim ds As New DataSet()
			ds.Locale = CultureInfo.InvariantCulture
			ds.EnforceConstraints = False
			ds.ReadXmlSchema(Path.Combine(DataPath, "TripSearchResponse.xsd"))
			ds.Tables("Result").Columns.Add("ImageData", GetType(Byte())) 'Add a column for the actual images.
			If UseOfflineData Then
				ds.ReadXml(Path.Combine(DataPath, "OfflineData.xml"))
			Else
				' Create the web request  
				Dim url As String = String.Format("http://travel.yahooapis.com/TripService/V1.1/tripSearch?appid=YahooDemo&query={0}&results=20", CityName)
				Dim uri As New UriBuilder(url)
				Dim request As HttpWebRequest = TryCast(WebRequest.Create(uri.Uri.AbsoluteUri), HttpWebRequest)

				' Get response  
				Using response As HttpWebResponse = TryCast(request.GetResponse(), HttpWebResponse)
					' Load data into a dataset  
					ds.ReadXml(response.GetResponseStream())
				End Using
			End If

			If ds.Tables("ResultSet").Rows.Count <= 0 Then
				Throw New Exception("Error loading the data.")
			End If
			If Convert.ToInt32(ds.Tables("ResultSet").Rows(0)("totalResultsReturned")) <= 0 Then
				Throw New Exception("There are no travel plans for this location")
			End If

			LoadImageData(ds, UseOfflineData, DataPath)

			' Uncomment this code to create an offline image of the data.
#If (CreateOffline) Then
			ds.WriteXml(Path.Combine(DataPath, "OfflineData.xml"))
#End If

			reportStart.AddTable(ds)
		End Sub

		Friend ReadOnly Property MainException() As Exception
			Get
				Return FMainException
			End Get
		End Property

		Private Shared Sub LoadImageData(ByVal ds As DataSet, ByVal UseOfflineData As Boolean, ByVal DataPath As String)
			Dim Images As DataTable = ds.Tables("Image")
			Images.PrimaryKey = New DataColumn() { Images.Columns("Result_Id") }
			For Each dr As DataRow In ds.Tables("Result").Rows
				Dim ImageRow As DataRow = Images.Rows.Find(dr("Result_Id"))

				If ImageRow Is Nothing Then
					Continue For
				End If
				Dim url As String = Convert.ToString(ImageRow("Url"))
				If url IsNot Nothing AndAlso url.Length > 0 Then
					dr("ImageData") = LoadIcon(url, UseOfflineData, DataPath)
				End If
			Next dr

		End Sub

		Friend Shared Function LoadIcon(ByVal url As String, ByVal useOfflineData As Boolean, ByVal dataPath As String) As Byte()
			If useOfflineData Then
				Dim u As New Uri(url)
				Return LoadFileIcon(Path.Combine(dataPath, u.Segments(u.Segments.Length - 1)))
			Else
				' Uncomment this code to create an offline image of the data. 
#If (CreateOffline) Then
				Dim u As New Uri(url)
				Dim IconData() As Byte = LoadWebIcon(url)
				Using fs As New FileStream(Path.Combine(dataPath, u.Segments(u.Segments.Length - 1)), FileMode.Create)
					fs.Write(IconData, 0, IconData.Length)
				End Using
#End If


				Return LoadWebIcon(url)

			End If
		End Function

		''' <summary>
		''' On a real implementation this should be cached.
		''' </summary>
		''' <param name="url"></param>
		''' <returns></returns>
		Friend Shared Function LoadWebIcon(ByVal url As String) As Byte()
			Using wc As New WebClient()
				Return wc.DownloadData(url)
			End Using
		End Function

		Private Shared Function LoadFileIcon(ByVal filename As String) As Byte()
			Using fs As New FileStream(filename, FileMode.Open)
				Dim Result(CInt(fs.Length) - 1) As Byte
				fs.Read(Result, 0, Result.Length)
				Return Result
			End Using
		End Function


	End Class

End Namespace

Program.vb

Namespace HTML
	Friend NotInheritable Class Program

		Private Sub New()
		End Sub

		''' <summary>
		''' The main entry point for the application.
		''' </summary>
		<STAThread> _
		Shared Sub Main()
			Application.EnableVisualStyles()
			Application.SetCompatibleTextRenderingDefault(False)
			Application.Run(New mainForm())
		End Sub
	End Class
End Namespace

ProgressDialog.Designer.vb

Imports System.Collections
Imports System.ComponentModel
Imports System.Threading
Imports FlexCel.Render
Namespace HTML
	Partial Public Class ProgressDialog
		Inherits System.Windows.Forms.Form

		Private statusBar1 As System.Windows.Forms.StatusBar
		Private statusBarPanel1 As System.Windows.Forms.StatusBarPanel
		Private statusBarPanelTime As System.Windows.Forms.StatusBarPanel
		Private labelCaption As System.Windows.Forms.Label
		Private pictureBox1 As System.Windows.Forms.PictureBox
		''' <summary>
		''' Required designer variable.
		''' </summary>
		Private components As System.ComponentModel.Container = Nothing

		''' <summary>
		''' Clean up any resources being used.
		''' </summary>
		Protected Overrides Sub Dispose(ByVal disposing As Boolean)
			If disposing Then
				If components IsNot Nothing Then
					components.Dispose()
				End If
			End If
			MyBase.Dispose(disposing)
		End Sub

		#Region "Windows Form Designer generated code"
		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()
			Dim resources As New System.Resources.ResourceManager(GetType(ProgressDialog))
			Me.statusBar1 = New System.Windows.Forms.StatusBar()
			Me.statusBarPanel1 = New System.Windows.Forms.StatusBarPanel()
			Me.statusBarPanelTime = New System.Windows.Forms.StatusBarPanel()
			Me.labelCaption = New System.Windows.Forms.Label()
			Me.timer1 = New System.Timers.Timer()
			Me.pictureBox1 = New System.Windows.Forms.PictureBox()
			CType(Me.statusBarPanel1, System.ComponentModel.ISupportInitialize).BeginInit()
			CType(Me.statusBarPanelTime, System.ComponentModel.ISupportInitialize).BeginInit()
			CType(Me.timer1, System.ComponentModel.ISupportInitialize).BeginInit()
			Me.SuspendLayout()
			' 
			' statusBar1
			' 
			Me.statusBar1.Location = New System.Drawing.Point(0, 128)
			Me.statusBar1.Name = "statusBar1"
			Me.statusBar1.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() { Me.statusBarPanel1, Me.statusBarPanelTime})
			Me.statusBar1.ShowPanels = True
			Me.statusBar1.Size = New System.Drawing.Size(448, 22)
			Me.statusBar1.TabIndex = 1
			' 
			' statusBarPanel1
			' 
			Me.statusBarPanel1.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None
			Me.statusBarPanel1.Text = "Elapsed Time:"
			Me.statusBarPanel1.Width = 80
			' 
			' statusBarPanelTime
			' 
			Me.statusBarPanelTime.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None
			Me.statusBarPanelTime.Text = "0:00"
			' 
			' labelCaption
			' 
			Me.labelCaption.Anchor = (CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
			Me.labelCaption.Location = New System.Drawing.Point(16, 16)
			Me.labelCaption.Name = "labelCaption"
			Me.labelCaption.Size = New System.Drawing.Size(408, 16)
			Me.labelCaption.TabIndex = 2
			Me.labelCaption.Text = "Retrieving data from Webservice..."
			' 
			' timer1
			' 
			Me.timer1.Enabled = True
			Me.timer1.SynchronizingObject = Me
'			Me.timer1.Elapsed += New System.Timers.ElapsedEventHandler(Me.timer1_Elapsed)
			' 
			' pictureBox1
			' 
			Me.pictureBox1.Image = (CType(resources.GetObject("pictureBox1.Image"), System.Drawing.Image))
			Me.pictureBox1.Location = New System.Drawing.Point(64, 40)
			Me.pictureBox1.Name = "pictureBox1"
			Me.pictureBox1.Size = New System.Drawing.Size(296, 64)
			Me.pictureBox1.TabIndex = 3
			Me.pictureBox1.TabStop = False
			' 
			' ProgressDialog
			' 
			Me.AutoScaleDimensions = New System.Drawing.SizeF(6F, 13F)
			Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
			Me.ClientSize = New System.Drawing.Size(448, 150)
			Me.ControlBox = False
			Me.Controls.Add(Me.pictureBox1)
			Me.Controls.Add(Me.labelCaption)
			Me.Controls.Add(Me.statusBar1)
			Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
			Me.MaximizeBox = False
			Me.MinimizeBox = False
			Me.Name = "ProgressDialog"
			Me.ShowInTaskbar = False
			Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
			Me.Text = "Please wait..."
'			Me.Closed += New System.EventHandler(Me.ProgressDialog_Closed)
			CType(Me.statusBarPanel1, System.ComponentModel.ISupportInitialize).EndInit()
			CType(Me.statusBarPanelTime, System.ComponentModel.ISupportInitialize).EndInit()
			CType(Me.timer1, System.ComponentModel.ISupportInitialize).EndInit()
			Me.ResumeLayout(False)

		End Sub
		#End Region
	End Class
End Namespace


ProgressDialog.vb

Imports System.Collections
Imports System.ComponentModel

Imports System.Threading

Imports FlexCel.Render

Namespace HTML
	''' <summary>
	''' A dialog box to show progress.
	''' </summary>
	Partial Public Class ProgressDialog
		Inherits System.Windows.Forms.Form

		Private WithEvents timer1 As System.Timers.Timer

		Public Sub New()
			InitializeComponent()
		End Sub


		Private StartTime As Date
		Private RunningThread As Thread

		Private Sub timer1_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles timer1.Elapsed
			UpdateStatus()
		End Sub

		Public Sub ShowProgress(ByVal aRunningThread As Thread)
			RunningThread = aRunningThread

			If Not RunningThread.IsAlive Then
				DialogResult = System.Windows.Forms.DialogResult.OK
				Return
			End If
			timer1.Enabled = True
			StartTime = Date.Now
			ShowDialog()
		End Sub

		Private Sub UpdateStatus()
			Dim ts As TimeSpan = Date.Now.Subtract(StartTime)
			Dim hours As String
			If ts.Hours = 0 Then
				hours = ""
			Else
				hours = ts.Hours.ToString("00") & ":"
			End If
			statusBarPanelTime.Text = hours & ts.Minutes.ToString("00") & ":" & ts.Seconds.ToString("00")

			If Not RunningThread.IsAlive Then
				DialogResult = System.Windows.Forms.DialogResult.OK
			End If
		End Sub

		Private Sub ProgressDialog_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
			timer1.Enabled = False
		End Sub
	End Class
End Namespace