SpreadsheetGear 2023
Core Spreadsheet Engine
SpreadsheetGear 2023 > Tutorials > Core Spreadsheet Engine

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

Create a new Console Application

  1. Launch Visual Studio 2012, Visual Studio 2013, Visual Studio 2015, Visual Studio 2017, Visual Studio 2019 or Visual Studio 2022.
  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 2023

  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, select SpreadsheetGear 2023 Core Engine and SpreadsheetGear 2023 GDI+ Drawing Library for use with .NET 4.6.2+, or select SpreadsheetGear 2023 for .NET 3.5 for use with .NET 3.5+.
  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
  1. 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.