[]
        
(Showing Draft Content)

Adding NuGet Package in Spread Windows Forms

The following section explains how to use Spread Windows Forms in a .NET Framework and .NET 6 platform by using GrapeCity.Spread.WinForms NuGet package.

.NET Framework

Follow the below steps to create a Windows Forms application in .NET Framework platform:

  1. Click on 'Create a new project' and select 'Windows Forms App (.NET Framework)'.

    Spread.NET developers select the Windows Forms App (.NET Framework) project template in Visual Studio to create a compatible application.

  2. Name the project and click Create.

  3. Right click on References and click 'Manage NuGet Packages'.

    Spread.NET developers open the References context menu in Solution Explorer and select Manage NuGet Packages to add the control.

  4. Search 'Grapecity.Spread' and install GrapeCity.Spread.WinForms NuGet package in your solution.

    Spread.NET developers locate GrapeCity.Spread.WinForms in NuGet Package Manager and select Install to add the package to a Windows Forms project.

  5. Right click Properties and add a new item.

    Spread.NET developers open the Properties context menu in Solution Explorer and choose Add New Item to create licensing metadata.

  6. Add a text file from 'Add new item' dialog and name it as licenses.licx.

    Spread.NET developers add licenses.licx under Properties and reference GrapeCity.Spread.WinForms so the Windows Forms project includes licensing information.

  7. Add Spread's license string as follows:

    FarPoint.Win.Spread.FpSpread, FarPoint.Win.Spread

  8. Switch to the designer, and drag drop the fpSpread control on the form. Set the Name, Size, Sheet Count, and Cell Text properties from the Properties window.

    OR

    Double click Form1.cs and add the fpSpread control using the following code in its form load event.

    FpSpread fpSpread1 = new FpSpread();
    fpSpread1.Location = new System.Drawing.Point(52, 12);
    fpSpread1.Name = "fpSpread1";
    fpSpread1.Size = new System.Drawing.Size(653, 380);
    fpSpread1.Sheets.Count = 2;
    this.Controls.Add(fpSpread1);
    fpSpread1.ActiveSheet.Cells[0, 0].Text = "Welcome";
  9. Build the project and run to view fpSpread control on to the Form.

.NET 6

Follow the below steps to create a Windows Forms application in .NET 6 platform:

  1. Click on 'Create a new project' and select 'Windows Forms App (.NET)'.

    Spread.NET developers select the Windows Forms App (.NET) template in Visual Studio to create a modern Windows Forms project.

  2. Name the project and click Create.

  3. Right click on References and click 'Manage NuGet Packages'.

  4. Search 'Grapecity.Spread' and install GrapeCity.Spread.WinForms NuGet package in your solution.

    Spread.NET developers locate GrapeCity.Spread.WinForms in NuGet Package Manager and select Install to add the package to a Windows Forms project.

  5. Switch to the designer, and drag drop the fpSpread control on the form. Set the Name, Size, Sheet Count, and Cell Text properties from the Properties window.

    OR

    Double click Form1.cs and add the fpSpread control using the following code in its form load event.

    FpSpread fpSpread1 = new FpSpread();
    fpSpread1.Location = new System.Drawing.Point(52, 12);
    fpSpread1.Name = "fpSpread1";
    fpSpread1.Size = new System.Drawing.Size(653, 380);
    fpSpread1.Sheets.Count = 2;
    this.Controls.Add(fpSpread1);
    fpSpread1.ActiveSheet.Cells[0, 0].Text = "Welcome";


  6. Build the project and run to view fpSpread control on to the Form.

!type=note

Note: Licenses.licx file with FpSpread license string isn't required in .NET 6 application.

To work with the Spread Designer in your project using NuGet packages, refer to the topic Using Spread Designer in Runtime.