Saves a Worksheet as a PDF document to the specified stream.

 public static void SavePdf(System.IO.Stream stream)
Public Static Sub SavePdf(ByVal stream As System.IO.stream)

The output stream to write to. This stream must be open and writable. ExcelWriter will not close this stream; the calling program is responsible for closing the stream and releasing the resource.

 

If there is a problem creating, opening, or writing to the stream specified, or reading from the Worksheet object.

The Worksheet.PageSetup property will be used to specify how the worksheet should be rendered to the PDF document.  The individual PageSetup options are reflected in the final document.

           ExcelApplication xla = new ExcelApplication();
           Workbook WB= xla.Create(FileFormat.Xlsx);
           Worksheet worksheet = WB[0];
           FileStream fstream = new FileStream(@"C:\temp\outfile.pdf", FileMode.Create);           
           worksheet.SavePdf(fstream);            
	   Dim oExcelApp As New ExcelApplication()           
           Dim WB As Workbook = oExcelApp.Create(FileFormat.Xlsx) 
           Dim worksheet As Worksheet = WB[0]
           Dim fstream As New FileStream("C:\temp\outfile.pdf", FileMode.Create)          
           worksheet.SavePdf(fstream)