SpreadsheetGear 2010
Core Spreadsheet Engine
Send Feedback
SpreadsheetGear 2010 > Tutorials > Core Spreadsheet Engine

Glossary Item Box

Follow these steps to create a simple Console Application which demonstrates the SpreadsheetGear 2010 Core Engine.

Create a new Console Application

  1. Launch Visual Studio 2005, Visual Studio 2008 or Visual Studio 2010.
  2. On the File menu, point to New and click Project. The New Project dialog box appears.
  3. Under Project Types / Templates, choose Visual C# -> Windows -> Console Application.
  4. Change the Name and Location as desired.
  5. Click OK to create the project.

Add a reference to SpreadsheetGear 2010

  1. In Solution Explorer, select the project you just created.
  2. On the Project menu, click Add Reference. The Add Reference dialog box appears.
  3. In the Add Reference dialog box, click the .NET tab. A list of .NET components appears.
  4. In the list of .NET components, click SpreadsheetGear 2010.
  5. Click OK to add the reference. 

Add code to create a workbook and calculate a value

  1. In Solution Explorer, open the source file which contains the Main(...) method (the default is Program.cs).
  2. Replace the Main() method with:

    Simple Core Engine Sample

    Copy Code
    static void Main(string[] args)
    {
        // Create a new empty workbook in a new workbook set.
        SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
        // Get a reference to the first worksheet.
        SpreadsheetGear.IWorksheet worksheet = workbook.Worksheets["Sheet1"];
        // Get a reference to the top left cell of Sheet1.
        SpreadsheetGear.IRange a1 = worksheet.Cells["A1"];
        // Set a formula.
        a1.Formula = "=24901.55 / PI()";
        // Output the result of the formula.
        Console.WriteLine("The diameter of the earth is " + a1.Value + " miles.");
    } 

Build and run the application

  1. Build menu, click Build Solution. The solution builds with no errors.
  2. On the Debug menu, click Start Without Debugging. The application runs in a console window and displays:

The diameter of the earth is 7926.40954629997 miles.

Copyright © 2003-2010 SpreadsheetGear LLC.   All Rights Reserved.Help Powered by Innovasys