This sample demonstrates how to export data table into clipboard.
private void btnClipboard_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.Clipboard.ClipboardExport clipboardExport1
= new Spire.DataExport.Clipboard.ClipboardExport();
clipboardExport1.DataFormats.CultureName = "zh-CN";
clipboardExport1.DataFormats.Currency = "c";
clipboardExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
clipboardExport1.DataFormats.Float = "g";
clipboardExport1.DataFormats.Integer = "g";
clipboardExport1.DataFormats.Time = "H:mm";
clipboardExport1.ShowContent = true;
clipboardExport1.SQLCommand = oleDbCommand1;
oleDbConnection1.Open();
clipboardExport1.SaveToFile();
}
Private Sub btnClipboard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClipboard.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 clipboardExport1 As New Spire.DataExport.Clipboard.ClipboardExport()
clipboardExport1.DataFormats.CultureName = "zh-CN"
clipboardExport1.DataFormats.Currency = "c"
clipboardExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
clipboardExport1.DataFormats.Float = "g"
clipboardExport1.DataFormats.[Integer] = "g"
clipboardExport1.DataFormats.Time = "H:mm"
clipboardExport1.ShowContent = True
clipboardExport1.SQLCommand = oleDbCommand1
oleDbConnection1.Open()
clipboardExport1.SaveToFile()
End Sub