Saturday, 03 July 2010 09:28

Spire.XLS for .NET Quick Start

In this document, we will quickly help you finish a simple demo about Spire.XLS using Visual Studio. As usual, it’s a HelloWorld demo. Before you get started, please make sure the Spire.XLS 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 in which you installed the Spire.XLS, default is "C:\Program Files\e-iceblue\Spire.XLS", 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.XLS.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:

[C#]
private void btnRun_Click(object sender, EventArgs e)
[VB.NET]
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

[C#]
using Spire.Xls;
[VB.NET]
Imports Spire.Xls

6. Add the following codes to the method btnRun_Click

[C#]
//Creates workbook
Workbook workbook = new Workbook();

//Gets first worksheet
Worksheet sheet = workbook.Worksheets[0];

//Writes hello world to A1
sheet.Range["A1"].Text = "Hello,World!";

//Save workbook to disk
workbook.SaveToFile("Sample.xls");

try
{
System.Diagnostics.Process.Start(workbook.FileName);
}
catch { }
[VB.NET]
'Creates workbook
Dim workbook As Workbook = New Workbook()

'Gets first worksheet
Dim sheet As Worksheet = workbook.Worksheets(0)

'Writes hello world to A1
sheet.Range("A1").Text = "Hello,World!"

'Save workbook to disk
workbook.SaveToFile("Sample.xls")

Try
System.Diagnostics.Process.Start(workbook.FileName)
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', an Excel document will be created, edited and opened. The string "Hello, World" is filled in the cell A1.

Saturday, 03 July 2010 06:54

EXCEL Read Comment in C#, VB.NET

 

The sample demonstrates how to read comment from an excel workbook.

ReadComment.gif

Saturday, 03 July 2010 02:51

EXCEL Write Hyperlinks in C#, VB.NET

 

The sample demonstrates how to write hyperlinks into spreadsheet.

WriteHyperlinks.gif

Saturday, 03 July 2010 01:46

EXCEL Read Hyperlinks in C#, VB.NET

 

The sample demonstrates how to read hyperlinks from spreadsheet.

ReadHyperlinks.gif

Saturday, 03 July 2010 01:14

EXCEL Wite Formulas in C#, VB.NET

 

The sample demonstrates how to write formulas into spreadsheet..

WriteFormulas.gif

Saturday, 03 July 2010 01:07

EXCEL Read Formulas in C#, VB.NET

 

The sample demonstrates how to read formulas from spreadsheet.

ReadFormulas.gif

Saturday, 03 July 2010 01:00

EXCEL Data Export in C#, VB.NET


The sample demonstrates how to export the data from spreadsheet to datatable.



Saturday, 03 July 2010 00:50

EXCEL Data Import in C#, VB.NET

 

The sample demonstrates how to import the data from datatable to spreadsheet.

DataImport.gif

Saturday, 03 July 2010 00:40

EXCEL Edit Chart Sheet in C#, VB.NET

 

The sample demonstrates how to edit chart worksheet in an excel workbook.

EditChart.gif

Saturday, 03 July 2010 00:30

EXCEL Pie Charts in C#, VB.NET

 

The sample demonstrates how to create a pie chart in an excel workbook.

Pie.gif

Page 21 of 22