Skip to main content Skip to footer

How to set the ExcelIO LicenseKey in Angular

NOTE: When using PureJS environment, ExcelIO is not required to be licensed separately.

Background:

When working in Angular and using the ExcelIO namespace, if when importing or exporting an xlsx file there is an additional Evaluation Sheet that is being generated, this is because the ExcelIO namespace must be set separately from the SpreadSheets namespace. Both will be set with the same distribution key.

Steps to Complete:

1. Import both namespaces

2. Set the LicenseKey for both namespaces

Getting Started:

Import namespaces

import * as GC from "@grapecity/spread-sheets"; 
import * as ExcelIO from "@grapecity/spread-excelio";

Set LicenseKey properties for the namespace

const license = "MyLicense"; 
GC.Spread.Sheets.LicenseKey = license; 
ExcelIO.LicenseKey = license;

Note: For SpreadJS v12.2.0 or later users

You will see an error saying: Property ‘LicenseKey’ does not exist on type 'typeOf’ Excel.

This is due to a current typescript definition

To fix this, change the ExcelIO type to ‘any’ like below:

//There's two different way you could set it
//Set as:
(<any>ExcelIO).LicenseKey = license;
//Or:
(ExcelIO as any).LicenseKey = license;

Tags:

Mackenzie Albitz