This sample demonstrates how to export data table to HTML.
private void button1_Click(object sender, EventArgs e)
{
System.Data.OleDb.OleDbConnection oleDbConnection1
= new System.Data.OleDb.OleDbConnection();
oleDbConnection1.ConnectionString
= @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\..\..\Database\demo.mdb";
System.Data.OleDb.OleDbCommand oleDbCommand1
= new System.Data.OleDb.OleDbCommand();
oleDbCommand1.CommandText = "select * from parts";
oleDbCommand1.Connection = oleDbConnection1;
Spire.DataExport.HTML.HTMLExport htmlExport1
= new Spire.DataExport.HTML.HTMLExport();
htmlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
htmlExport1.DataFormats.CultureName = "zh-CN";
htmlExport1.DataFormats.Currency = "c";
htmlExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
htmlExport1.DataFormats.Float = "g";
htmlExport1.DataFormats.Integer = "g";
htmlExport1.DataFormats.Time = "H:mm";
htmlExport1.FileName = "test.html";
htmlExport1.HtmlTableOptions.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(122)), ((System.Byte)(236)));
htmlExport1.HtmlTableOptions.FontColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
htmlExport1.HtmlTableOptions.HeadersBackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(0)), ((System.Byte)(0)));
htmlExport1.HtmlTableOptions.HeadersFontColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
htmlExport1.HtmlTableOptions.OddBackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(107)), ((System.Byte)(206)));
htmlExport1.HtmlTextOptions.BackgroundColor = System.Drawing.Color.FromArgb(((System.Byte)(51)), ((System.Byte)(51)), ((System.Byte)(153)));
htmlExport1.HtmlTextOptions.Font = new System.Drawing.Font("Arial", 8F);
htmlExport1.HtmlTextOptions.FontColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
htmlExport1.HtmlTextOptions.LinkActiveColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(255)), ((System.Byte)(0)));
htmlExport1.HtmlTextOptions.LinkColor = System.Drawing.Color.FromArgb(((System.Byte)(105)), ((System.Byte)(239)), ((System.Byte)(125)));
htmlExport1.HtmlTextOptions.LinkVisitedColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(0)), ((System.Byte)(255)));
htmlExport1.SQLCommand = oleDbCommand1;
oleDbConnection1.Open();
try
{
htmlExport1.HtmlStyle = Spire.DataExport.HTML.HtmlStyle.Plain;
htmlExport1.SaveToFile();
}
finally
{
oleDbConnection1.Close();
}
}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oleDbConnection1 As New System.Data.OleDb.OleDbConnection()
oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\..\..\Database\demo.mdb"
Dim oleDbCommand1 As New System.Data.OleDb.OleDbCommand()
oleDbCommand1.CommandText = "select * from parts"
oleDbCommand1.Connection = oleDbConnection1
Dim htmlExport1 As New Spire.DataExport.HTML.HTMLExport()
htmlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
htmlExport1.DataFormats.CultureName = "zh-CN"
htmlExport1.DataFormats.Currency = "c"
htmlExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
htmlExport1.DataFormats.Float = "g"
htmlExport1.DataFormats.[Integer] = "g"
htmlExport1.DataFormats.Time = "H:mm"
htmlExport1.FileName = "test.html"
htmlExport1.HtmlTableOptions.BackColor = System.Drawing.Color.FromArgb(CByte(0), CByte(122), CByte(236))
htmlExport1.HtmlTableOptions.FontColor = System.Drawing.Color.FromArgb(CByte(255), CByte(255), CByte(255))
htmlExport1.HtmlTableOptions.HeadersBackColor = System.Drawing.Color.FromArgb(CByte(255), CByte(0), CByte(0))
htmlExport1.HtmlTableOptions.HeadersFontColor = System.Drawing.Color.FromArgb(CByte(255), CByte(255), CByte(255))
htmlExport1.HtmlTableOptions.OddBackColor = System.Drawing.Color.FromArgb(CByte(0), CByte(107), CByte(206))
htmlExport1.HtmlTextOptions.BackgroundColor = System.Drawing.Color.FromArgb(CByte(51), CByte(51), CByte(153))
htmlExport1.HtmlTextOptions.Font = New System.Drawing.Font("Arial", 8.0F)
htmlExport1.HtmlTextOptions.FontColor = System.Drawing.Color.FromArgb(CByte(255), CByte(255), CByte(255))
htmlExport1.HtmlTextOptions.LinkActiveColor = System.Drawing.Color.FromArgb(CByte(0), CByte(255), CByte(0))
htmlExport1.HtmlTextOptions.LinkColor = System.Drawing.Color.FromArgb(CByte(105), CByte(239), CByte(125))
htmlExport1.HtmlTextOptions.LinkVisitedColor = System.Drawing.Color.FromArgb(CByte(255), CByte(0), CByte(255))
htmlExport1.SQLCommand = oleDbCommand1
oleDbConnection1.Open()
Try
htmlExport1.HtmlStyle = Spire.DataExport.HTML.HtmlStyle.Plain
htmlExport1.SaveToFile()
Finally
oleDbConnection1.Close()
End Try
End Sub