Please see the document (with example) on how Aspose.Cells can digitally sign vba code project for your reference:
If you still could not make it work and find any issue, kindly do provide input file, digital signature file (.pfx) and output file. Also, paste your runnable code here to reproduce the issue, we will check it soon.
We have investigated it more and found that VBA project signature is not supported in .NET Core yet. We have logged the issue in our database for a fix. Once, we will have some news for you, we will update you in this topic.
This issue has been logged as
CELLSNETCORE-49 - Sign VBA Project on .Net Core API
Sadly I can’t download your attached v20.3.3 download, it shows me an error:
Sorry, this file is private. Only visible to topic owner and staff members.
Can you please allow me downloading the file too, so that I can try and test?
I’m also wondering about the version: You named it v20.3.3 and the latest one avaliable on NuGet is 20.9.0. Shouldn’t your fix already be included in 20.9.0 or is it an independent fork for .NET standard so that we can’t compare the version number from NuGet?
string excelFile = @"C:\...\testfile.xlsm";
string targetExcelFile = @"C:\...\testfile-signed.xlsm";
string certPath = @"C:\..\my-cert.pfx";
string certPw = "xxx";
var cert = new X509Certificate2(certPath, certPw);
var workbook = new Workbook(excelFile);
var signature = new Aspose.Cells.DigitalSignatures.DigitalSignature(cert, "Aspose.Cells added new digital signature in existing digitally signed workbook.", DateTime.Now);
var stream = workbook.SaveToStream();
byte outputBuffer = stream.ToArray();
Please provide a sample VS.NET project (runnable) with .pfx (with password) and other template files, zip the project and post us or share via some file sharing service (e.g Google drive, dropbox), we will check it soon. Moreover, the following line of code is not right: var stream = workbook.SaveToStream();
Please save to XLSM stream via relevant Workbook.Save() overloads instead. Please note, Workbook.SaveToStream saves the file in older XLS file format.
By the way, did you test your scenario/ case on Windows if it works on it or not?
Using those cert from the docs it throws the same not implemented exception. So we know that it’s not related to my cert and you can use the demo one to reproduce it. I made you a complete VS project with those example cert/excel file from the docs:
@ahsaniqbalsidiqui This works great! Thank you very much for the fast help
Can you please add those bug with the constructor overload to our bug tracker and document this in the example article Digitally Sign a VBA Code Project with Certificate|Documentation ? That’s where I got the overload with X509Certificate2. I think this would be helpfull for others since the example code doesn’t work with those overload, only when passing the cert as byte array together with the password as you posted in the example.