How to display print preview and then print the excel

hi,

i have test in excel2010, also showed 19 pages.

please see the attachment.


the snap picture is from win7 computer.

hi,


you are right,we talk about the diff sheet before.
in my code i use SheetRender render the sheet2(not sheet1),

file render in excel

file render by SheetRender(aspose)

can you please take some sample code to output print preview files which exactly like excel effect.


thanks

Hi Pyntia,


Please check the attached spreadsheet and execute the following code against it on your side. This spreadsheet is the same as of your shared sample, however, I have manually changed the paper size to A4 as shown on your snapshot. The code should print 5 pages in Sheet 1 & 19 pages in Sheet 2, as it is on my side.

C#

Workbook book = new Workbook(“D:/sample.xlsx”);
foreach (Worksheet sheet in book.Worksheets)
{
SheetRender render = new SheetRender(sheet, new ImageOrPrintOptions());
Console.WriteLine(render.PageCount + " pages in " + sheet.Name);
}

Hi Pyntia,


My fellow colleague has raised a concern, that is; you are probably viewing the Print Preview with “Print Entire Workbook” option selected. We are not sure because you have the Excel application with Non-English installation, however, you will get the idea from the attached snapshot. If you view the Print Preview with “Print Entire Workbook” option, you will get all the pages of the worksheets combines, whereas “Print Active Sheets” will give the pages of the active worksheet.

If you wish to achieve the same behavior as of “Print Entire Workbook” with Aspose.Cells, please consider using WorkbookRender class as follow.

C#

Workbook book = new Workbook(“D:/sample.xlsx”);
WorkbookRender render = new WorkbookRender(book, new ImageOrPrintOptions());
Console.WriteLine(render.PageCount + " pages in Workbook");

hi


i found the really reason.

i have used DevExpress UI control in my application. and i use below code to set the ui control fit the DPI.

DevExpress.XtraEditors.WindowsFormsSettings.SetDPIAware();

i think may be this cause SheetRender calulate error pagesize.

today, there has many high resolution computer,please support non normal dpi scenario.


thanks

Hi Pyntia,


I am not sure if the said behavior can be caused due to the DevExpress integration in your application, however, we can look into the matter if you can provide us an executable standalone application along with it’s dependencies (referenced assemblies). Please create/start a new thread for better visibility of your requests/inquiries.

What about the results with my shared sample spreadsheet and code? What results have you received with it? Please also share the snapshot of the Control Panel > Display window as shown in attached screenshot.