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

Free Support Forum - aspose.com

Printing Worksheets

Hi. I am evaluating the component Aspose. Cells and me the following doubts have arisen.

It wanted to know how it is possible to print a worksheets on an application asp.net. It is possible to select a printer by code? If it is possible, one might show it in an example asp .net c#?

It is possible to turn a worksheets in pdf using aspose.cells or it would have to buy also aspose.pdf ?



Thanks for considering Aspose.

1). Well we introduced new API and you may use Worksheet.SheetToPrinter method which supports printing worksheets.



/// Prints the worksheet

/// The printer name
public void SheetToPrinter(String PrinterName)

2). Yes, you can convert excel file to .pdf format. But, you do need to use Aspose.Pdf for .NET too. Check the following doc how you can write the code:


Thank you.

Hi. Thank you for the response.

I have updated the demo aspose.cells to the version 4.5 and have assigned the printer.

Other one doubts that I have is the following one:

The worksheet that I want to print occupies 5 pages.

page 1: A1:X58

page 2: A59:X120

page 3: A121:X177

page 4: A178:X236

page 5: A237:X297

How I can establish the properties in order that it me prints the pages correctly, in an alone work of impression?.

Nowadays, the worksheet has the area of impression formed but at the moment of printing it is not born in mind.

Workbook workbook = new Workbook ();
Workbook. Open ("C:\report.xls");
Workbook. Worksheets ["Report"] .SheetToPrinter ("MyPrinter");

Thanks you.


Could you try:

Workbook workbook = new Workbook ();
workbook. Open ("C:\report.xls");

Aspose.Cells.PageSetup pageSetup = workbook.Worksheets["Report"].PageSetup;
pageSetup.PrintArea = "A1:X58, A59:X120, A121:X177, A178:X236, A237:X297";

workbook. Worksheets ["Report"] .SheetToPrinter ("MyPrinter");

Thank you.


Could you attch your template file report.xls here?

Printing worksheet feature depend on various printers. We don't test for all case. so maybe have bugs in current version.

Hello. Thank you for your help.
An example of excel with that I work I attach it in this message.

The workbook has two worksheets: Report and Informe. Report contains the information and Informe contains links and formula on the above mentioned information. I need to print only Informe worksheets.

I have several doubts:

1. If my Informe worksheet has areas of impression definite, why on having done
Workbook workbook = new Workbook ();
Workbook. Open ("C:\example.xls");

Workbook. Worksheets ["Informe"] .SheetToPrinter ("Microsoft Office Document Image Writer");

It does not appear well?

I have used Microsoft Office Document Image Writer, PDFCreator, ... (virtual printers PDF) to print pdf of tests.

2. I need to print on an alone document (with several pages) the Informe worksheet. I have tried to define the following :

PageSetup pageSetup = workbook. Worksheets ["Informe"] .PageSetup;
PageSetup. Orientation = PageOrientationType. Landscape;
PageSetup. Zoom = 11;
PageSetup. PrintArea = "A1:U58, A121:X177, A178:X236, A237:X297 ";

PageSetup. FitToPagesWide = 1;
PageSetup. FitToPagesTall = 1;

But in the instruction next:

workbook.Worksheets["Informe"].SheetToPrinter("Microsoft Office Document Image Writer");

a mistake takes is produced of "invalid cell name".

In addition if only I use the option:

PageSetup. PrintArea = "A1:U58";

landscope it does not work, and the document does not appear correctly.

3. Also I am proving the component aspose.pdf.

In the same way that exists the instructions:

workbook.Worksheets ["Informe"].SheetToPrinter ("Microsoft Office Document Image Writer");

Why do not I have an instruction that selected worksheets guards in format pdf? Something as this:

workbook.Worksheets ["Informe"].Save(@"C:\MySpreadsheet.xml", FileFormatType.AsposePdf);

Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf();

//Bind the XML file (containing spreadsheet data) with the Pdf object

pdf1.BindXML(@"C:\MySpreadsheet.xml", null);

//Create the PDF document by calling its Save method


I only need to print one worksheets. Then I need to select only Informe worksheets:

Workbook singleSheet = new Workbook();

for (int rowIndex = 0; rowIndex <= workbook.Worksheets["Informe"].Cells.MaxRow; rowIndex++)


for (int colIndex = 0; colIndex <= workbook.Worksheets["Informe"].Cells.MaxColumn; colIndex++)


object objValue = workbook.Worksheets["Informe"].Cells[rowIndex, colIndex].Value;

Aspose.Cells.Style objStyle = workbook.Worksheets["Informe"].Cells[rowIndex, colIndex].GetStyle();

singleSheet.Worksheets[0].Cells[rowIndex, colIndex].SetStyle(objStyle);

singleSheet.Worksheets[0].Cells[rowIndex, colIndex].PutValue(objValue);




//// Save the document in Aspose.Pdf.Xml format

singleSheet.Save(@"C:\MySpreadsheet.xml", FileFormatType.AsposePdf);

I need to copy data and style, and this, to part of that does not work well, it consumes a lot of time. Then to generate a pdf consumes a lot of time because I have to remain alone with a worksheet and then to print it.

Can you help me, please? Is very important.

Thanks you.

Hi. By means of the property workbook:

Worksheets ["Report"] .IsVisible = false; I can conceal the worksheets that I do not want to print. I can create a temporary workbook with only visibly the worksheets in that I am interested.

What I still have for resolving is how I form the parameters of the page in order that one sees well the pages of the Informe worksheets.



Thanks for providing us details.

We will try to fix your issue soon. We 'll keep you updated about your issue.

Thank you.


About print issue, please try the attached fix.

Please test using the following codes with the excel file you have provided. I think the fix solves most questions except the style of some cells.

Workbook workbook = new Workbook();
workbook.Worksheets["Informe"].SheetToPrinter("Microsoft Office Document Image Writer");