Free, Trial, and Professional Modes
GemBox.Spreadsheet library has four working modes:
Every working mode uses the same GemBox.Spreadsheet.dll file and delivers the same performance and set of features, but has some restrictions (except for the Professional mode).
Before using any other member of GemBox.Spreadsheet, you must call a To set the mode to Free, use the 'FREE-LIMITED-KEY' key. The default behavior of the Free mode is that a You can change this behavior by handling a You can use the Free mode for any purpose, including use in commercial applications. The Trial mode is the same as Free, with the difference that when you handle a When a limitation is reached, instead of throwing an exception or stopping the load or save process approximately 5% of randomly selected cells will have their value replaced with TRIAL. To set the mode to Time Limited, you need to use a time-limited key, which you can get by contacting our support. The time-limited key is valid only for 30 days but it allows you to use the component without any limitations. To set the mode to Professional, you need to use a professional key which you can get by purchasing a license. The Professional mode has no limitations, and the professional keys are perpetual (they can be used forever). Note that every developer working on an application that uses the GemBox component in a Professional mode must be covered with a license. The professional keys are uniquely generated for each license and must be kept confidential. For more information, please read the FAQ page and the product's EULA. If you're working on an open-source project, please make sure that your license is not publicly accessible. One way to keep the professional key out of your source code is to bind your project's configuration to an external source that's not included in the project, like a secret file or environment variable. As a result, the secret file that has your professional key will be generated on one of the following locations. Another way to store your professional key is to use an external secrets management service, such as Azure Key Vault, AWS Key Management Service, or Google Cloud Key Management Service.SpreadsheetInfo.SetLicense
method to set the working mode.Free
FreeLimitReachedException
is thrown when a limitation, like loading or saving an Excel file with more than 150 rows or 5 sheets, is reached.SpreadsheetInfo.FreeLimitReached
event and setting FreeLimitEventArgs.FreeLimitReachedAction
to Stop
.As an example, when loading an Excel file with more than 5 sheets, the process will stop after 5 sheets are loaded.// Set license key to use GemBox.Spreadsheet in a Free mode.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
// Stop reading/writing a spreadsheet when the free limit is reached.
SpreadsheetInfo.FreeLimitReached += (sender, e) => e.FreeLimitReachedAction = FreeLimitReachedAction.Stop;
' Set license key to use GemBox.Spreadsheet in a Free mode.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
' Stop reading/writing a spreadsheet when the free limit is reached.
AddHandler SpreadsheetInfo.FreeLimitReached, Sub(sender, e) e.FreeLimitReachedAction = FreeLimitReachedAction.Stop
Trial
SpreadsheetInfo.FreeLimitReached
event you set FreeLimitEventArgs.FreeLimitReachedAction
to ContinueAsTrial
.// Set license key to use GemBox.Spreadsheet in a Free mode.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
// Continue to use the component in a Trial mode when free limit is reached.
SpreadsheetInfo.FreeLimitReached += (sender, e) => e.FreeLimitReachedAction = FreeLimitReachedAction.ContinueAsTrial;
' Set license key to use GemBox.Spreadsheet in a Free mode.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
' Continue to use the component in a Trial mode when free limit is reached.
AddHandler SpreadsheetInfo.FreeLimitReached, Sub(sender, e) e.FreeLimitReachedAction = FreeLimitReachedAction.ContinueAsTrial
Time Limited
Professional
// Set license key to use GemBox.Spreadsheet in a Professional mode.
SpreadsheetInfo.SetLicense("XXXXXXXXXX");
' Set license key to use GemBox.Spreadsheet in a Professional mode.
SpreadsheetInfo.SetLicense("XXXXXXXXXX")
Keeping your license key secret in .NET framework
userSecretsId
value.appSettings
in the app.config file that uses the previously added configuration builder and has an empty license key.<configuration>
<configSections>
<section name="configBuilders"
type="System.Configuration.ConfigurationBuildersSection,
System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
restartOnExternalChanges="false"
requirePermission="false" />
</configSections>
<configBuilders>
<builders>
<add name="Secrets"
userSecretsId="31c68e26-876c-43f5-8bb4-d87c9ec5f1ce"
type="Microsoft.Configuration.ConfigurationBuilders.UserSecretsConfigBuilder,
Microsoft.Configuration.ConfigurationBuilders.UserSecrets, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</builders>
</configBuilders>
<appSettings configBuilders="Secrets">
<add key="GemBoxLicenseKey" value="" />
</appSettings>
</configuration>
%APPDATA%\Microsoft\UserSecrets\<userSecretsId>\secrets.xml
<root>
<secrets ver="1.0">
<secret name="GemBoxLicenseKey" value="XXXXXXXXXX" />
</secrets>
</root>
using GemBox.Spreadsheet;
using System.Configuration;
class Program
{
static Program()
{
var license = ConfigurationManager.AppSettings["GemBoxLicenseKey"];
SpreadsheetInfo.SetLicense(license);
}
static void Main()
{
var workbook = new ExcelFile();
var worksheet = workbook.Worksheets.Add("Sample");
var cell = worksheet.Cells[0, 0];
cell.Value = "Sample";
workbook.Save("Sample.xlsx");
}
}
Imports GemBox.Spreadsheet
Imports System.Configuration
Module Program
Sub New()
Dim license = ConfigurationManager.AppSettings("GemBoxLicenseKey")
SpreadsheetInfo.SetLicense(license)
End Sub
Sub Main()
Dim workbook = New ExcelFile()
Dim worksheet = workbook.Worksheets.Add("Sample")
Dim cell = worksheet.Cells(0, 0)
cell.Value = "Sample"
workbook.Save("Sample.xlsx")
End Sub
End Module
Keeping your license key secret in .NET Core
dotnet user-secrets init
dotnet user-secrets set GemBoxLicenseKey XXXXXXXXXX%APPDATA%\Microsoft\UserSecrets\<UserSecretsId>\secrets.json
~/.microsoft/usersecrets/<UserSecretsId>/secrets.json
{
"GemBoxLicenseKey": "XXXXXXXXXX"
}
using GemBox.Spreadsheet;
using Microsoft.Extensions.Configuration;
using System.Linq;
class Program
{
static Program()
{
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
var provider = config.Providers.First();
provider.TryGet("GemBoxLicenseKey", out string license);
SpreadsheetInfo.SetLicense(license);
}
static void Main()
{
var workbook = new ExcelFile();
var worksheet = workbook.Worksheets.Add("Sample");
var cell = worksheet.Cells[0, 0];
cell.Value = "Sample";
workbook.Save("Sample.xlsx");
}
}
Imports GemBox.Spreadsheet
Imports Microsoft.Extensions.Configuration
Imports System.Linq
Module Program
Sub New()
Dim config = New ConfigurationBuilder().AddUserSecrets(Of Program)().Build()
Dim provider = config.Providers.First()
Dim license As String = Nothing
provider.TryGet("GemBoxLicenseKey", license)
SpreadsheetInfo.SetLicense(license)
End Sub
Sub Main()
Dim workbook = New ExcelFile()
Dim worksheet = workbook.Worksheets.Add("Sample")
Dim cell = worksheet.Cells(0, 0)
cell.Value = "Sample"
workbook.Save("Sample.xlsx")
End Sub
End Module