Free Support Forum - aspose.com

Convert xls to xps and strech result xps

Hello,

I am converting excel files to xps. I use Aspose.Cells.Rendering.SheetRender class for this.
My excel contains sheets with many columns. During conversion, my sheet is divided into few parts, and in result document each part is on separate page. So after conversion I got something like document in attach(result.xps).
Then I try to set FitToPagesWide property to 1 and I got my sheet on one page in result document, but it is scaled and too small(scaled.xps)

So my question is: How can I stretch xps document, to put whole worksheet on one page and save source scaling(width of sheet).

Thanks for replies.

Hi,


Well, your xps file would be generated based on the print preview shown in MS Excel for the worksheet(s), so if a worksheet is split on multiple pages, Aspose.Cells would render the XPS file according to it. I think for your need, you may try, e.g

Sample code:

//Open an Excel file
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(“e:\test\Book1.xls”);
//Get the first worksheet
Aspose.Cells.Worksheet sheet = workbook.Worksheets[0];

//Apply different Image and Print options
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
//Set this options for your need.
options.OnePagePerSheet = true;

//Set the Format
options.SaveFormat = SaveFormat.XPS;
//Render the sheet with respect to specified printing options
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, options);
sr.ToImage(0, “e:\test2\out_printingxps.xps”);

Thank you.