How to convert a password protected Spreadsheet to PDF in C#

Hello,

We are using GroupDocs.Conversion for .NET. When we want to convert password protected file (tried excel and word format) we get following error “xlsx” and nothing more. It also happens when I use your website for conversion:

https://products.groupdocs.app/conversion/total

image.png (172.1 KB)

3 Monthly Cost report encrypted.zip (12.9 KB)

Api version : 20.6.0

Could it be improved in the future? Do you need some more information ?

Br,
Piotr

1 Like

@pibel

Are you using back-end API in your .NET application? Can you please provide password for this XLSX and we’ll investigate it at our end.

I also tried with empty excel file which was password protected, so it is not related with that particular file. Regarding word file, it works fine, my bad.
Could you please tell me what you mean by
“Are you using back-end API in your .NET application?”?

@pibel

From this we meant, are you using GroupDocs.Conversion DLL in your .NET application (developing your own document converter using version 20.6) or you’re just evaluating our web application? We have a dedicated forum for our web apps.

Just first one, we use Conversion dll

@pibel

Thank you for the details. Have a look at the following code:

GroupDocs.Conversion.Contracts.Func<LoadOptions> getLoadOptions = () => new SpreadsheetLoadOptions
{
	Password = "123"
};
using (var converter = new Converter(@"D:/test.xlsx", getLoadOptions))
{

	var options = new PdfConvertOptions();
	converter.Convert(@"D:/output.pdf",options);
}

We tried to convert a sample password protected XLSX file to PDF and it worked well using API version 20.6/20.7. Have a loo at these files.zip (20.9 KB).
In order to further investigate this scenario, please share following details:

  • Sample code
  • Password for the XLSX file

Sorry, maybe I did not make myself clear. For my case we have excel document which is password protected and we don’t want to pass password here. We just want to get correct information why conversion was unsuccessful. Consider following code

        string documentPath = @"D:\test.docx";
        try
        {
            using (var converter = new GroupDocs.Conversion.Converter(documentPath))
            {
                var options = new GroupDocs.Conversion.Options.Convert.PdfConvertOptions();
                converter.Convert(@"D:\converted.pdf", options);
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

if we pass .docx file (password protected) here, we get exception “Password is required to convert password protected document”.
However, when I pass xlsx file the exception looks like “xlsx” which says nothing particular. And using your website (Online File Conversion | Free GroupDocs Apps) produce same error.

I hope now it is more clear.

@pibel

Thank you for the clarification. We’ve logged an investigation ticket (CONVERSIONNET-4087) in our issue tracking system to fix exception details for password protected XLSX file conversion. As there’s any update, you’ll be notified.

Ok, thank you!:slight_smile:

1 Like

@pibel

You’re welcome.

The issues you have found earlier (filed as CONVERSIONNET-4087) have been fixed in this update. This message was posted using Bugs notification tool by Atir_Tahir