Excel Save - Aspose PDF

Hello,

I’ve download both Aspose.Excel and Asspose.Pdf and have manged to save an Excel file as XML and then converted it to a PDF. However this saves/converts the whole Excel workbook. Is it possible to save to save a cellrange and convert this?

Aspose.Excel.Excel excel = new Aspose.Excel.Excel();

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

excel.Open(@“C:\Work\Testing\Allsorts\Comments.xls”);

excel.Save(@“C:\Work\Testing\Allsorts\comment.xml”,FileFormatType.AsposePdf);

pdf.BindXML(@“C:\Work\Testing\Allsorts\comment.xml”,null);

pdf.Save(@“C:\Work\Testing\Allsorts\comment.pdf”);

You can set Print Area for that cell range. Then only that range of cells will be converted.

Do you mean by opening excel and setting print area or can this be done by the Aspose.Excel component.

These two approaches should all work.

@theMadLad,
Aspose.Cells has replaced Aspose.Excel that is no more under active development now. This new product not only contains all the features of its predecessor but it also supports the latest features in different versions of MS Excel. Page area can be set and rendered to PDF using the PageSetup class object. The following example demonstrates this feature:

// Open the template workbook
Workbook workbook = new Workbook("Book1.xlsx");

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

PageSetup pageSetup = worksheet.PageSetup;

// Specifying the cells range (from A1 cell to E30 cell) of the print area
pageSetup.PrintArea = "A1:E30";

// Defining column numbers A & E as title columns
pageSetup.PrintTitleColumns = "$A:$E";

// Defining row numbers 1 as title rows
pageSetup.PrintTitleRows = "$1:$2";

// Allowing to print gridlines
pageSetup.PrintGridlines = true;

// Allowing to print row/column headings
pageSetup.PrintHeadings = true;

// Allowing to print worksheet in black & white mode
pageSetup.BlackAndWhite = true;

// Allowing to print comments as displayed on worksheet
pageSetup.PrintComments = PrintCommentsType.PrintInPlace;

// Allowing to print worksheet with draft quality
pageSetup.PrintDraft = true;

// Allowing to print cell errors as N/A
pageSetup.PrintErrors = PrintErrorsType.PrintErrorsNA;

// Setting the printing order of the pages to over then down
pageSetup.Order = PrintOrderType.OverThenDown;

// Save the workbook
workbook.Save("PageSetup_Print_out.pdf");

Input File


Output File

For more details on PageSetup and Printing Options follow the below link:
Page Setup and Printing Options

Download the latest trial version here:
Aspose.Cells for .NET (Latest Version)

Here is a ready to run solution which can be used to test the product features.