Documents for Excel, .NET Edition Documentation
Get Started / License Information
In This Topic
    License Information
    In This Topic

    Types of Licenses

    GcExcel .NET supports the following types of license:

    Unlicensed

    When you download GcExcel for the first time, the product works under No-License i.e Unlicensed mode with a few limitations, that are highlighted below.

    Evaluation License

    GcExcel .NET trial license is available for one month for users to evaluate the product and see how it can help with their comprehensive project requirements.

    In order to evaluate the product, you can contact us.sales@grapecity.com and ask for the evaluation license key. The evaluation key is sent to users via email and holds valid for 30 days. After applying the evaluation license successfully, the product can be used without any limitations until the license date expires.

    After the expired date, the following limitations will be triggered:

    Licensed

    GcExcel .NET production license is issued at the time of purchase of the product. If you have production license, you can access all the features of GcExcel .NET without any limitations.

    Apply License To GcExcel .NET

    Applying license to GcExcel .NET involves completing the following steps to create and license a WorkBook:

    Step 1: Create a new Web Application (.NET Core)

    1. In Visual Studio, select File | New | Project to create a new ASP.NET Core Web Application.
    2. From the 'New Project' dialog, select Installed | Visual C# | .NET Core | ASP.NET Core Web Application, and click OK.
    3. In the 'New ASP.NET Core Web Application(.NET Core)' dialog, select Web Application (Model-View-Controller), and click OK.
    4. Add the GcExcel .NET references to the project. In the Solution Explorer, right click Dependencies and select Manage NuGet Packages. In NuGet Package Manager, select nuget.org as the Package source. Search for 'grapecity.documents', select GrapeCity.Documents.Excel, and click Install.

    Step 2: Add a Controller

    1. In the Solution Explorer, right click the folder Controllers.
    2. From the context menu, select Add | Controller. The Add Scaffold dialog appears.
    3. Complete the following steps in the Add Scaffold dialog:
      • Select MVC Controller-Empty and click Add.
      • Set name of the MVC controller (For example: GcExcelController) and click Add.
    4. Add the GcExcel reference in Controller file:
      using GrapeCity.Documents.Excel;
    5. In the Index() method of the Controller, add the following code:                
      GcExcelController.cs
      Copy Code
      public IActionResult Index()
              {
                  Workbook workbook = new Workbook();
                  workbook.Worksheets[0].Range["A1"].Value = "Hello Word!";                  
                  workbook.Save(@"D:\HelloWord.xlsx");
      
                  return View();        
              }

    A new Controller is added to the application within the folder Controllers.

    Step 3: Add License

    1. Add the product license key in one of the ways, either to license all the workbooks or just a specific workbook. These are explained below:

      • To license all the workbooks in a project, add the license key in Startup.cs file by using SetLicenseKey method. This will license all the workbooks even across multiple Controllers.          
        Startup.cs
        Copy Code
        public Startup(IConfiguration configuration)
                {
                    //Apply license before using the API, otherwise it will be considered as no license.
                    Workbook.SetLicenseKey(" Your License Key");
                         
                }

      • To license an instance of the workbook, add the license key when an instance of workbook is created. Add the following code in the Index() method of the controller:
        GcExcelController.cs
        Copy Code
        public IActionResult Index()
                {
                    //Apply license before using the API, otherwise it will be considered as no license.
                    var workbook = new Workbook("Your License Key");
                         
                }

    Step 4: Add a View

    1. From the Solution Explorer, right click the folder Views and select Add | New Folder.
    2. Name the new folder. Provide the same name as the name of your controller, minus the suffix Controller (in our example: GcExcel).
    3. Right click the folder GcExcel, and select Add | View. The Add MVC View dialog appears.
    4. Complete the following steps in the Add MVC View dialog:
      • Set View name same as the Action name, Index (for example: Index.cshtml).
      • Click Add.
    5. Replace the code in Index.cshtml file with below:
      Index.cshtml
      Copy Code
      @{
      ViewData["Title"] = "Documents for Excel, .Net Edition";
      }
      <script>
          onload = function () {
             alert("File Saved at D:\HelloWord.xlsx");
      }
      </script>

    Step 5: Build and Run the Project

    1. Click Build | Build Solution to build the project.
    2. Press F5 to run the project.
    3. Once the project is executed, access the URL: http://localhost:1234/GcExcel/Index to generate the Excel file. An alert box is displayed and HelloWord.xlsx file is created at the specified location.