.NET (1316)
Children categories
In this document, we will quickly help you finish a simple demo about Spire.DataExport using Visual Studio. Before you get started, please make sure the Spire.DataExport and Visual Studio (2008 or later) are installed on your computer.
1. In Visual Studio, click File, New, and then Project, If you want to create a C# project, select Visual C#, Windows and choose Windows Forms Application and name the project SimpleCellExport. Click OK. If you want to create a Visual Basic project, select Visual Basic, Windows Forms Application and name the project SimpleCellExport. Click OK.
2. In Solution Explorer, right-click the project SimpleCellExport and click Properties. In the Application tab, check the Target framework, the target framework can must be a full version not a client profile version.
3. In Solution Explorer, right-click the project SimpleCellExport and click Add Reference. In the Browse tab, find the folder which you installed the Spire.DataExport in, default is "C:\Program Files\e-iceblue\Spire.DataExport", double-click the folder Bin. If the target framework of the project SimpleCellExport
- is .NET 2.0, double-click folder NET2.0
- is .NET 3.5, double-click folder NET3.5
- is .NET 4.0, double-click folder NET4.0
select these two assemblies: Spire.DataExport.dll and Spire.DataExport.ResourceMgr.dll, and click OK to add it to the project.
4. In Solution Explorer, double-click the file Form1.cs/Form1.vb to open the form design view, add a button into the form, and change its name to 'btnRun', change its text to 'Run'.
5. Open the ToolBox window, select the control 'CellExport' in the 'Spire.DataExport' tab and drag it into the form.
6. Select the new control object under the form in the design window, open the Properties window, change the name of the control 'CellExport' to 'cellExport', set the property ActionAfterExport to OpenView, set the property FileName to any file path you wanted, for example: D:\temp\sample.xls.
7. Double-click the button 'Run', you will see the code view and the following method has been added automatically
private void btnRun_Click(object sender, EventArgs e)
***Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRun.Click
8. Add the following codes to the top of the file
using System.Data; using System.Data.OleDb;
Imports System.Data Imports System.Data.OleDb
9. Add the following codes to the method btnRun_Click
using (IDbConnection conn = new OleDbConnection())
{
//the data source demo.mdb was installed during installing Spire.DataExport,
//so the path of the data source may be different yours.
conn.ConnectionString
= @"Provider=Microsoft.Jet.OLEDB.4.0;"
+ @"Data Source=C:\Program Files\e-iceblue\Spire.DataExport\Demos\Database\demo.mdb";
conn.Open();
IDbCommand command = new OleDbCommand();
command.Connection = conn;
command.CommandText = "select * from parts";
this.cellExport.SQLCommand = command;
this.cellExport.SaveToFile();
}
Using conn = new OleDbConnection() 'the data source demo.mdb was installed during installing Spire.DataExport, 'so the path of the data source may be different yours. conn.ConnectionString _ = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=C:\\Program Files\\e-iceblue\\Spire.DataExport\\Demos\\Database\\demo.mdb" conn.Open() Dim command As New OleDbCommand() command.Connection = conn command.CommandText = "select * from parts" Me.cellExport.SQLCommand = command Me.cellExport.SaveToFile() End Using
10. In Solution Explorer, right-click the project SimpleCellExport and click Debug, then Start new instance, you will see the opened window Form1, click the button 'Run', an Excel workbook will be generated, and opened. It looks the same as the following picture:

In this document, we will quickly help you finish a simple demo about Spire.Doc using Visual Studio. As usual, it's a HelloWorld demo. Before you get started, please make sure the Spire.Doc and Visual Studio (2008 or later) are installed on your computer.
1. In Visual Studio, click File, New, and then Project, If you want to create a C# project, select Visual C#, Windows and choose Windows Forms Application and name the project HelloWorld. Click OK. If you want to create a Visual Basic project, select Visual Basic, Windows Forms Application and name the project HelloWorld. Click OK.
2. In Solution Explorer, right-click the project HelloWorld and click Add Reference. In the Browse tab, find the folder which you installed the Spire.Doc in, default is "C:\Program Files\e-iceblue\Spire.Doc", double-click the folder Bin. If the target framework of the project HelloWorld
- is .NET 2.0, double-click folder NET2.0
- is .NET 3.5, double-click folder NET3.5
- is .NET 4.0, double-click folder NET4.0
select assembly Spire.Doc.dll and click OK to add it to the project.
3. In Solution Explorer, double-click the file Form1.cs/Form1.vb to open the form design view, add a button into the form, and change its name to 'btnRun', change its text to 'Run'.
4. Double-click the button 'Run', you will see the code view and the following method has been added automatically:
private void btnRun_Click(object sender, EventArgs e)
Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRun.Click
5. Add the following codes to the top of the file:
using Spire.Doc; using Spire.Doc.Documents;
Imports Spire.Doc Imports Spire.Doc.Documents
6. Add the following codes to the method btnRun_Click
//Create word document
Document document = new Document();
//Create a new paragraph
Paragraph paragraph = document.AddSection().AddParagraph();
//Append Text
paragraph.AppendText("Hello World!");
//Save doc file.
document.SaveToFile("Sample.doc", FileFormat.Doc);
//Launching the MS Word file.
try
{
System.Diagnostics.Process.Start("Sample.doc");
}
catch { }
'Create word document
Dim document_Renamed As New Document()
'Create a new paragraph
Dim paragraph_Renamed As Paragraph = document_Renamed.AddSection().AddParagraph()
'Append Text
paragraph_Renamed.AppendText("Hello World!")
'Save doc file.
document_Renamed.SaveToFile("Sample.doc", FileFormat.Doc)
'Launching the MS Word file.
Try
System.Diagnostics.Process.Start("Sample.doc")
Catch
End Try
7. In Solution Explorer, right-click the project HelloWorld and click Debug, then Start new instance, you will see the opened window Form1, click the button 'Run', a Word document will be created, edited and opened. The string "Hello, World" is filled in the first line of page 1.

This sample demonstrates how to export data table to text/sylk/csv/dif file.

The picture above represents using Excel application to open a SYLK type output file.
This sample demonstrates how to export data table to sql script.

This sample demonstrates how to export data table into xml file.

This sample demonstrates how to export data table into ms-access file.

The picture above represents using Excel application to open the result ms-access file.
This sample demonstrates how to export data table into dbf file.

The picture above represents using Excel application to open the result dbf file.
This sample demonstrates how to export data table into clipboard.

This sample demonstrates how to export data table into rtf file.

This sample demonstrates how to export data table into pdf file.
