SpreadsheetGear® 2009
Core Spreadsheet Engine
Send Feedback
Tutorials > Core Spreadsheet Engine

Glossary Item Box

Follow these steps to create a simple Console Application which demonstrate the SpreadsheetGear 2009 Core Engine.

Create a new Console Application

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

Add a reference to SpreadsheetGear 2009

  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 2009.
  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-2009 SpreadsheetGear LLC. All Rights Reserved.Help Powered by Innovasys   
SpreadsheetGear is a registered trademark of SpreadsheetGear LLC.
Microsoft, Microsoft Excel and Visual Studio are trademarks or registered trademarks of Microsoft Corporation.