ExcelToPdfConverter is inaccessible due to its protection level

NOTE: I could not find the XL control in the dropdown above, and it wouldn't let me continue without selecting one, so I chose PDF Viewer, even though that's not the right one.


I've used NuGet to install XLIO and renderer.

I was able to create the workbook and download it per your example code.

But I want to convert the workbook to a pdf and download that instead.

When I type ExcelToPdfConverter, I get an error:

ExcelToPdfConverter is inaccessible due to its protection level

What am I missing?


4 Replies

KA Keith A Price July 28, 2021 08:02 PM UTC

I poked around and experimented and I now think your documentation for Blazor XL is inaccurate and incomplete -- or at least the sample code is wrong (maybe outdated?)/


Here's what worked for me:


                //Save the document as a stream and return the stream.

                XlsIORenderer renderer = new();

                PdfDocument pdfDoc = new();

                pdfDoc = renderer.ConvertToPDF(worksheet);



                using ( MemoryStream stream = new MemoryStream() )

                {

                    //Save the created Excel document to MemoryStream

                    //workbook.SaveAs(stream); // to save and download as Excel

                    pdfDoc.Save(stream);


                    return stream;

                }



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team July 29, 2021 08:38 AM UTC

Hi Keith, 

Greetings from Syncfusion. 

  1. You must have installed Syncfusion.XlsIORenderer.Net.Core NuGet package, which is a .NET Standard NuGet package into your .NET Standard application but using ExcelToPdfConverter class, which is available in only .NET Framework.
  2. This causes compilation issue in your .NET Standard application.
  3. ExcelToPdfConverter class is named as XlsIORenderer in .NET Standard and hence XlsIORenderer class should be used in .NET Standard applications.

We are glad that you have found this and modified the code in your application to overcome the issue. Please go through the below links where this is documented. 


We request you to share the documentation link you have viewed, which will be helpful for us in modifying it, if the content is inaccurate. 

Regards, 
Keerthi. 



KA Keith A Price July 29, 2021 03:08 PM UTC

So, I guess I'm confused. My app is a Net Core app, so did I install the right NuGet packages?




I couldn't find anything in the documentation that explained the need for different code when in Core. The end result  in my project is fantastic, but I gotta say it was a pretty frustrating experience figuring out how to make it work with the sample code and documentation.



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team July 30, 2021 06:35 AM UTC

Hi Keith, 

You are using correct NuGet package in your application. In the documentation, we have provided code snippet in platform-wise tabs. Please look into the below screenshot. 

 

  1. If you are using WindowsForms or WPF you can use the code snippet provided under C# tab.
  2. Similarly for UWP application you can use the code snippet provided under UWP tab.
  3. Code snippet provided under ASP.NET Core tab should be used for ASP.NET Core application and code snippet provided under Xamarin tab should be used for Xamarin application.

In the same way, we have listed the NuGet packages that should be used in different platforms. However, we are glad that you have found proper code and this worked at your end. 

Kindly let us know if you need any further assistance. 

Regards, 
Keerthi. 


Loader.
Up arrow icon