We are using ASPOSE Total licensed version. We are not able to print Excel sheets using below code. I am using .Net 6. where System.Drawing is not supported.
Worksheet worksheet;
// Get the second sheet.
worksheet = workbook.Worksheets[1];
// Apply different Image/Print options.
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.PrintingPage = PrintingPageType.Default;
SheetRender sr = new SheetRender(worksheet, options);
Console.WriteLine("Printing SampleBook.xlsx");
// Print the sheet.
try
{
sr.ToPrinter(printerName);
Console.WriteLine("Pinting finished.");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Error: ‘SheetRender’ does not contain a definition for ‘ToPrinter’ and no accessible extension method ‘ToPrinter’ accepting a first argument of type ‘SheetRender’ could be found (are you missing a using directive or an assembly reference?)