Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Dec 23, 2021 12:47 pm

Hi,

I was trying to sign several times so i can add multiple signatures in the same excel file following sample code provided by your side in the below link, but unfortunately every time i sign a file with signature saves the file with only the latest signature (just one signature every time).

Sample code reference url:
Code: Select all
https://www.e-iceblue.com/Tutorials/Spire.XLS/Program-Guide/Security/Add-and-Delete-Digital-Signature-in-Excel-in-C-VB.NET.html


Could you please help in this issue?

Thanks.

hossamabdelmoaty
 
Posts: 3
Joined: Thu Dec 23, 2021 12:28 pm

Fri Dec 24, 2021 4:06 am

Hello,

Thank you for your inquiry.
I did an initial test, but did not reproduce your issue. I have attached my test code and a screenshot of the test result file. The version I used is the latest version(Spire.XLS Pack(Hotfix) Version:11.12.2). If you were not using the latest version, please first give it a try. If the issue still exists after trying, please provide the following information for our reference. You could attach them here or send them to us via email (support@e-iceblue.com). Thanks in advance.
1) Your input excel file.
2) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
3) Your application type, such as Console app (. Net Framework 4.5).
4) Your tool for viewing the excel result file, such as MS Excel2016.
Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromFile(inputFile);
//Add certificate
String inputFile_pfx = "";
X509Certificate2 cert = new X509Certificate2(inputFile_pfx, "e-iceblue");
//Add signature
DateTime certtime = new DateTime(2020, 7, 1, 7, 10, 36);
workbook.AddDigitalSignature(cert, "e-iceblue", certtime);
workbook.AddDigitalSignature(cert, "e-iceblue", certtime);
workbook.AddDigitalSignature(cert, "e-iceblue", certtime);
workbook.AddDigitalSignature(cert, "e-iceblue", certtime);
//Save to file
workbook.SaveToFile(result, ExcelVersion.Version2010);

Sincerely,
Annika
E-iceblue support team
Attachments
screenshot.png
screenshot.png (4.6 KiB) Viewed 935 times
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Tue Dec 28, 2021 9:36 am

Hello,

I've tested your sample code provided in comment and it can add multiple signatures at the same time using the same cycle. What i need is to sign and save the file then sign the newly generated file with a sign to be signed again, the result in this case is just the last signature.
Provided below is sample code with both test cases mentioned above.

- This is your sample in last comment and add 4 signatures at the same time and same file:
Code: Select all
public void TestSignAllSignaturesOneSave(byte[] fileBytes, string newFileFullPath, DigitalCertificate cert)
{
    MemoryStream outputStream = new MemoryStream();

    try
    {
        MemoryStream inputStream = new MemoryStream(fileBytes);

        Workbook workbook = new Workbook();

        workbook.LoadFromStream(inputStream);

        X509Certificate2 certificate = cert.GetX509Certificate();

        IDigitalSignatures signatures;

        signatures = workbook.AddDigitalSignature(certificate, "201", DateTime.Now);
        signatures = workbook.AddDigitalSignature(certificate, "202", DateTime.Now);
        signatures = workbook.AddDigitalSignature(certificate, "203", DateTime.Now);
        signatures = workbook.AddDigitalSignature(certificate, "204", DateTime.Now);

        //Save the result file
        workbook.SaveToFile(newFileFullPath, FileFormat.Version2013);
    }
    catch (Exception ex)
    {
        throw;
    }
    finally
    {
        outputStream.Close();
    }
}


- This sample is what i use but just add one signature per cycle, i use it to sign a file and save it then use the newly signed file to sign again.
Code: Select all
public void TestSignOneSignaturePerSave(byte[] fileBytes, string newFileFullPath, DigitalCertificate cert)
{
    MemoryStream outputStream = new MemoryStream();

    try
    {
        MemoryStream inputStream = new MemoryStream(fileBytes);

        Workbook workbook = new Workbook();

        workbook.LoadFromStream(inputStream);

        //Add digital signature to the file
        X509Certificate2 certificate = cert.GetX509Certificate();

        IDigitalSignatures signatures;

        signatures = workbook.AddDigitalSignature(certificate, "100", DateTime.Now);

        //Save the result file
        workbook.SaveToFile(newFileFullPath, FileFormat.Version2013);
    }
    catch (Exception ex)
    {
        throw;
    }
    finally
    {
        outputStream.Close();
    }
}


Please advice as i need to sign excel with multiple signature in multiple cycles not in single operation.
Attachments
MultipleCycles.png
TestSignOneSignaturePerSave
MultipleCycles.png (12.64 KiB) Viewed 906 times
AllInOneCycle.png
TestSignAllSignaturesOneSave
AllInOneCycle.png (23.33 KiB) Viewed 906 times

hossamabdelmoaty
 
Posts: 3
Joined: Thu Dec 23, 2021 12:28 pm

Tue Dec 28, 2021 10:30 am

Hello,

Thank you for your inquiry.
I tested your code and did reproduce your issue. I have logged the issue into our bug tracking system with the ticket number SPIREXLS-3613. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Tue Jan 04, 2022 8:37 am

Hello,

Thank you for your latest reply. I'd like to know the fix expected release time for this issue so i can plan my schedule as my release time depends on your solution.

Thanks.

hossamabdelmoaty
 
Posts: 3
Joined: Thu Dec 23, 2021 12:28 pm

Tue Jan 04, 2022 10:25 am

Hello,

Our developers deal with the issues according to the customer's priority and deal with the purchasing customer first. However, I have informed our developers of your situation. Our developers will estimate the implementation time as soon as possible. I will keep you informed of any updates.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Tue Jan 18, 2022 7:49 am

Hello,

Thanks for your patience.
Regarding the issue SPIREXLS-3613, we want to confirm with you that after signing Excel multiple times you want all the signatures to be valid? Currently the result of our developer processing is that after signing the Excel file multiple times, all the signatures are preserved, but only the last one is valid. Can you accept this processing result?

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Mon Jan 24, 2022 10:05 am

Hello,

Thanks for your patience!

Glad to inform you that we just released Spire.XLS Pack Version:12.1 which fixes the issue of SPIREXLS-3613.

Please download the new version from the following links to test.

Website link: https://www.e-iceblue.com/Download/download-excel-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.XLS/12.1.0

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS

cron