How to print excel workbook?

Hi,support:
Is there any method to print a excel workbook?

@ducaisoft,

Please see the document on printing workbooks for your reference.

Thanks for your instruction.
And at least which version of the api support this Rendering method?
And what’s wrong about this issue(please refer to the attachment png)?
Excel.png (21.9 KB)

@ducaisoft,

Please note, Aspose.Cells has many namespaces having relevant classes and their members in it. The ImageOrPrintOptions class belongs to Aspose.Cells.Rendering namespace, so either you have to import that namespace at the top of your program or use fully qualified names (with respect to its namespace) when defining objects of the class. For complete reference about the APIs (which classes belong to which namespaces), please see the Aspose.Cells API Reference pages (see the .chm file (Aspose.Cells For .NET Documentation) at your installation directory or browse online API Reference pages here).

Thanks for your reply.
Here, I have an issue, that is to say:
If an Excel.xls or Excel.xlsx will be printed, the following codes will be for it like this:
Dim ExcelForPrint As New Global.Aspose.Cells.Workbook(sFile)
Dim ExcelPrintOp As New Global.Aspose.Cells.Rendering.ImageOrPrintOptions
ExcelPrintOp.OutputBlankPageWhenNothingToPrint =true
Dim ExcelSheetPrint As New Global.Aspose.Cells.Rendering.WorkbookRender(ExcelForPrint, ExcelPrintOp)
Dim Copies as integer=1 'I can know how many copies will be printed.
For p As Integer = 1 To Copies
ExcelSheetPrint.ToPrinter(PrinterName) 'The sheet 1 will be sent to PrinterName for printing, but I do not know how many pages in the sheet 1 will be printed.
Next
My issue is:
I want to know how many pages in the Sheet 1 will be sent to the printer for printing. But I do not want to use aspose.cells.dll to count how many pages in the sheet 1 before the sheet 1 will sent for print, whereas in the printing queue after sending to the printer, the printer status will display the details(please see the attached pic).
Could you know how to call windows api to get the details of the current printing queuce such as “Document Name / Status / Pages /Submitted”? Or the Aspose.cells.dll api support to getting the details of the current printing queuce such as “Document Name / Status / Pages /Submitted” once after performing ExcelSheetPrint.ToPrinter(PrinterName)?

Test.png (6.3 KB)
for the attached pic, the printer display there are 34 pages have been sent to the printer for pringting, how to get the pages value “34” by aspose.cells.dll or windows api?

Thanks for your help!

@ducaisoft,

Please note, Aspose.Cells only renders the workbook/worksheet to the printer and rest of the process or things would be done by the printer itself. Neither Aspose.Cells provides any APIs to get the details about the printing process or printer queries. Aspose.Cells sends the workbook/worksheet to the printer and that’s it, it does not establish any link to the underlying printer or print job. Aspose.Cells does provides relevant API to get the total number of pages to be printed or shown in Excel print preview (Aspose.Cells is a file format API and printing process tasks are out of scope/context), see the sample code segment on different ways to get total number of pages to be rendered for your reference:
e.g.
Sample code:

Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim printOptions As Aspose.Cells.Rendering.ImageOrPrintOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions()
printOptions.PrintingPage = PrintingPageType.Default
Dim sr As Aspose.Cells.Rendering.SheetRender = new Aspose.Cells.Rendering,SheetRender(worksheet, printOptions)
Dim pageCount As Integer = sr.PageCount
MessageBox.Show(pageCount.ToString())

Dim area() As CellArea = worksheet.GetPrintingPageBreaks(printOptions)
MessageBox.Show(area.Length.ToString())

Moreover, Aspose.Cells also provides WorkbookPrintingPreview and SheetPrintingPreview APIs that have EvaluatedPageCount attribute to get total number of pages.

You may browse internet to get relevant threads/details for the task, see some threads for your reference.

Thank you very much for your reference!
But for this reference How to get number of printed pages using system.printing?
I cannot access it and can not view its details. Would you please copy and post that VB.net demo here for me?

@ducaisoft,
Here is the PDF of the page which is referred here. We are afraid that we do not provide support for VB .NET and you are requested to use some online utility to convert C# .NET code to VB .NET.

c# - How to get number of printed pages using system.printing? - Stack Overflow.zip (77.7 KB)

Thank you very much.
I try to convert it.

But for the reference [Read printer pool to get number of pages being printed ]

why I cannot access its sub url [http://www.vbdotnetheaven.com/UploadFile/jodonnell/PrinterQueries04202005005917AM/PrinterQueries.aspx],would you please copy and post its VB.net demo for me ?
Thanks!

@ducaisoft,
We are afraid that we cannot help much in this regard and you should post in relevant thread to get the updated URL.