We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Workbook rendering to Printer

Can the Workbook Render to Printer method be used in an asp.net service or application on a Windows server? Does this method actually convert the Workbook to XPS format before printing? Is it possible to specify number of copies when using the Render to Printer method?


This message was posted using Page2Forum from WorkbookRender.ToPrinter Method - Aspose.Cells for .NET

Hi,


Please see the topic for your reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/printing-workbooks.html

Also, if you need to save to XPS, see the document:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/converting-to-xps.html

Moreover please use PageSetup.PrintCopies property to set Number of copies to be printed. Please see the following sample code in this regard.

//............
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Setting the orientation to Portrait
worksheet.PageSetup.Orientation = PageOrientationType.Portrait;
//setting number of copies to be printed
worksheet.PageSetup.PrintCopies = 1;
//..........


Thanks for the information.

When printing on a server using Render to Printer method (in an ASP.NET web service or application) is it necessary to do it from a separate thread where apartment state is set to STA as described at http://msdn.microsoft.com/en-us/library/aa969772.aspxv ? Or is this taken care of internally by the Aspose method?

The PageSetup property does not seem to be available for a Workbook. How can number of copies be specified when printing the entire workbook? If I set number of copies for each worksheet then print the entire workbook, the number of copies seems to be ignored. Printing each worksheet separately would not work for my application because worksheets 1 and 2 are each one-page documents and need to be on opposite sides of one sheet of paper. Just executing the rendering twice to get two copies does seem to work OK but seems more overhead than necessary.

Hi,


I am afraid, the number of print copies for PageSetup is ignored in Printing process, we will look into this feature soon. Also, we will get back to you to explain your regarding your other queries as well. A ticket is logged with an id: CELLSNET-40295. for it already.

Thank you.

@srundlett,

Please try our latest version/fix: Aspose.Cells for .NET v21.6.3 (attached)
Aspose.Cells21.6.3 For .Net2_AuthenticodeSigned.Zip (5.5 MB)
Aspose.Cells21.6.3 For .Net4.0.Zip (5.5 MB)
Aspose.Cells21.6.3 For .NetStandard20.Zip (5.5 MB)

Your issue should be fixed in it. See the sample code for your reference:
e.g.
Sample code:

Workbook wb = new Workbook("Book1.xlsx");

WorkbookRender wr = new WorkbookRender(wb, new ImageOrPrintOptions() { });

PrinterSettings printerSettings = new PrinterSettings();
printerSettings.Copies = 2;
printerSettings.PrinterName = "Microsoft Print to PDF";

wr.ToPrinter(printerSettings);

Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-40295) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao