Print page range

Hello Aspose,

I was wondering if it’s possible to print a page range , and if not if you can add this as a feature


my printing code is

if (windowManager.ShowDialog(modello, null, settings) == true)
{
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.PrintingPage = PrintingPageType.Default;

SheetRender sr = new SheetRender(modello.WorkBookAspose.Worksheets.First(), options);
sr.ToPrinter(modello.SelectedPrinter);

}

Thanks in advance

Hi Michele,

Thanks for your posting and using Aspose.Cells.

You can set the Print Area of the worksheet and then print the worksheet. For example, I have attached the source Excel file. I want to print just the range filled with yellow color, then I can use the following code.

I have also attached the printer output for your reference.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\sample.xlsx”;


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.Worksheets[0];


//Set print area

worksheet.PageSetup.PrintArea = “C3:I11”;


//Now print worksheet

SheetRender sr = new SheetRender(worksheet, new ImageOrPrintOptions());


sr.ToPrinter(“doPDF v7”);



Hello,

this doesn’t fit my needs… I need to allow the user to choose a page range (so or I’ve a way of knowing which cells fit on a page or something similar)

Hi Michele,

Thanks for your posting and using Aspose.Cells.

Please elaborate your requirements in more detail with some screenshots so that we could understand them precisely. We will investigate if such a feature is available or we need to implement it and log a New Feature request in our database to support it.

Thanks for your cooperation.

When I print a duco net I’ve got in the bottom the page number…I’ve created a print preview where the user can choose the orientation,margins and so on… I wish to allow him to select the page range to print (for example page 1to 4) as excel does

Thanks

Hi Michele,

Thanks for your posting and using Aspose.Cells.

I have attached the screenshot that highlights the feature you requested. Please confirm if this is the feature you need or you need something else.

Also, this feature is available while saving your Excel workbook into PDF format. However, it is not available when you directly print the workbook using WorkbookRender or SheetRender APIs.

Yes I really mean this… can you please add it to feature request portal and give me an ETA? do you think there’s a workaround till this feature is implemented with SheetRender’s API?

Hi Michele,

Thanks for your feedback and using Aspose.Cells.

If you can send PDF to printer then you can use this code to render selected page range to PDF format. I have attached the source Excel file and generated PDF for your reference.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;


Workbook workbook = new Workbook(filePath);


PdfSaveOptions opts = new PdfSaveOptions();


//Print 2,3 pages

opts.PageIndex = 1;

opts.PageCount = 2;


workbook.Save(“output.pdf”, opts);
We have also logged a New Feature request in our database to support your requirements. We will look into it and implement this feature. Once, the feature is implemented or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43256 - Printing range of pages using SheetRender and WorkbookRender

Perfect just a simple question how do I send the PDF directly to the printer?

Hi Michele,

Thanks for your posting and using Aspose.Cells.

You can use Aspose.Pdf to send your Printer to PDF. Please see the following code, it saves 2nd and 3rd pages into PDF using Aspose.Cells inside a MemoryStream and then send the PDF to the Printer from memory stream using Aspose.PDF.

You can also search on the internet if you could find some other way of sending PDF or any other File to printer using .NET framework APIs.

Besides, we have a good news for you. We have fixed this issue, so you will not have to use Aspose.PDF as a workaround. We will provide you a fix in couple of days probably on Friday.

C#


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;


using System.IO;

using Aspose.Cells;

using Aspose.Pdf;

using Aspose.Pdf.Facades;


namespace SimpleTest

{

class Program

{

static void Main(string[] args)

{

Environment.CurrentDirectory = @"F:\Shak-Data-RW\Downloads";


Workbook workbook = new Workbook(“source.xlsx”);


Aspose.Cells.PdfSaveOptions opts = new Aspose.Cells.PdfSaveOptions();


//Print 2,3 pages

opts.PageIndex = 1;

opts.PageCount = 2;


MemoryStream ms = new MemoryStream();

workbook.Save(ms, opts);


PdfViewer viewer = new PdfViewer();

viewer.BindPdf(ms);


viewer.PrintDocument();


}

}

}

Thanks a lot!

Hi,

Thanks for using Aspose.Cells.

We have fixed this issue.

Please download and try the latest fix: Aspose.Cells for .NET v8.3.1.2 and let us know your feedback.

We have added the API: ToPrinter(string
PrinterName, int PrintPageIndex, int PrintPageCount)
in
SheetRender.

The issues you have found earlier (filed as CELLSNET-43256) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.