Hi,
Thanks for your posting and using Aspose.Cells.
If you do not want to render your other worksheets, then you should hide them. Please check this
sample Excel file and the following sample code and its comments. Please also check the output pdf generated by the code for your reference. As you can see in the
output pdf that it only shows the contents of your target worksheet (as per your print area) and hide the contents of all other worksheets.
C#
//Load your source Excel file.
Workbook wb = new Workbook(dirPath + “sample769.xlsm”);
//Access your worksheet
Worksheet ws = wb.Worksheets[“Cover Letter - CPA”];
//Set its print area
PageSetup pageSetup = ws.PageSetup;
pageSetup.PrintArea = “C5:H12”;
//Hide all other worksheets because we don’t need them in pdf
int cnt = wb.Worksheets.Count;
for(int i=0; i<cnt; i++)
{
Worksheet sh = wb.Worksheets[i];
if(sh.Name.Equals(ws.Name)==false)
{
sh.IsVisible = false;
Console.WriteLine(sh.Name);
}
}
//Save the workbook into pdf
PdfSaveOptions opts = new PdfSaveOptions();
opts.OnePagePerSheet = true;
wb.Save(“output.pdf”, opts);