static void Main() { // If using Professional version, put your serial key below. SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY"); // Use Trial Mode SpreadsheetInfo.FreeLimitReached += (eventSender, args) => args.FreeLimitReachedAction = FreeLimitReachedAction.ContinueAsTrial; Console.WriteLine("Creating file"); // Create large workbook var workbook = new ExcelFile(); var worksheet = workbook.Worksheets.Add("sheet"); for (int i = 0; i < 1000000; i++) { worksheet.Cells[i, 0].Value = i; } // Create save options var saveOptions = new XlsxSaveOptions(); saveOptions.ProgressChanged += (eventSender, args) => { Console.WriteLine($"Progress changed - {args.ProgressPercentage}%"); }; // Save file workbook.Save("file.xlsx", saveOptions); }
static void Example2() { var workbook = ExcelFile.Load("SimpleTemplate.xlsx"); var signature1 = new XlsxDigitalSignatureSaveOptions() { CertificatePath = "GemBoxECDsa521.pfx", CertificatePassword = "******", CommitmentType = DigitalSignatureCommitmentType.Created, SignerRole = "Developer" }; // Embed intermediate certificate. signature1.Certificates.Add(new Certificate("GemBoxECDsa.crt")); var signature2 = new XlsxDigitalSignatureSaveOptions() { CertificatePath = "GemBoxRSA4096.pfx", CertificatePassword = "******", CommitmentType = DigitalSignatureCommitmentType.Approved, SignerRole = "Manager" }; // Embed intermediate certificate. signature2.Certificates.Add(new Certificate("GemBoxRSA.crt")); var saveOptions = new XlsxSaveOptions(); saveOptions.DigitalSignatures.Add(signature1); saveOptions.DigitalSignatures.Add(signature2); workbook.Save("XLSX Digital Signatures.xlsx", saveOptions); }
public override void Execute(GrapeCity.Documents.Excel.Workbook workbook) { //Change the path to real export path when save. XlsxSaveOptions options = new XlsxSaveOptions(); options.Password = "******"; workbook.Save(this.CurrentDirectory + "dest.xlsx", options); }
static void Example1() { var workbook = ExcelFile.Load("SimpleTemplate.xlsx"); var saveOptions = new XlsxSaveOptions(); saveOptions.DigitalSignatures.Add(new XlsxDigitalSignatureSaveOptions() { CertificatePath = "GemBoxECDsa521.pfx", CertificatePassword = "******" }); workbook.Save("XLSX Digital Signature.xlsx", saveOptions); }
static void Main() { // If using Professional version, put your serial key below. SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY"); // Use Trial Mode SpreadsheetInfo.FreeLimitReached += (eventSender, args) => args.FreeLimitReachedAction = FreeLimitReachedAction.ContinueAsTrial; // Create workbook var workbook = new ExcelFile(); var worksheet = workbook.Worksheets.Add("sheet"); for (int i = 0; i < 1000000; i++) { worksheet.Cells[i, 0].Value = i; } var stopwatch = new Stopwatch(); stopwatch.Start(); // Create save options var saveOptions = new XlsxSaveOptions(); saveOptions.ProgressChanged += (sender, args) => { // Cancel operation after five seconds if (stopwatch.Elapsed.Seconds >= 5) { args.CancelOperation(); } }; try { workbook.Save("Cancellation.xlsx", saveOptions); Console.WriteLine("Operation fully finished"); } catch (OperationCanceledException) { Console.WriteLine("Operation was cancelled"); } }