Hi Support desk,
I am working on evaulation copy of Aspose.cells dll to convet excel file to PDf file.
Below is my code snippet:
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_QuickStart();
var destinationFileName = dataDir + “Xls2PdfSaveOut.pdf”;
// creating file formats
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
//Instantiate the Workbook object
Workbook workbook = new Workbook(dataDir + “Test1.xlsx”);
//execute workbook formulas before pdf generation
workbook.CalculateFormula(true);
//Open an excel file
// workbook.Open(dataDir + “XlsTestingFile.xls”);
// The above method is not present in aspose.cell dll , i am using so commenting this.
// Worksheet worksheet = workbook.Worksheets[worksheetCount-1];
foreach (Worksheet worksheet in workbook.Worksheets)
{
worksheet.AutoFitColumns();
var typeWorksheet = worksheet.Type;
worksheet.PageSetup.PrintQuality = 180;
worksheet.PageSetup.CenterVertically = true;
worksheet.AutoFitColumns();
worksheet.PageSetup.PaperSize = PaperSizeType.PaperA4;
}
//Implement one page per worksheet option
var pdfSaveOptions = new PdfSaveOptions {AllColumnsInOnePagePerSheet = true,};
//Save the document in Pdf format
workbook.Save(destinationFileName, Aspose.Cells.SaveFormat.Pdf);
Console.WriteLine("\n Excel Document converted to PDF successfully.\nFile saved at " + dataDir + “Xls2PdfSaveOut.pdf”);
Attached the excel file and pdf after conversion.
Hi,
Hi Amjad,
Thanks for quick response. I understand your logic for conversion. I want to change the print setup properties programmatically to view the all columns in one excel. can you help on that.
Hi,
Hi Thank you for reply.
I am having one more issue. The excel is not printing the all rows from one of worksheets.
programmatically, I dont know which excel will have this issue in print set up.
Can you help me to identify the methods for printing the complete rows for excel for which print preview somewhat doesnot take all rows for starnge reasons.
Hi,