|
void exportbtn_Click(object sender, EventArgs e)
{
ExportToPDF(this.spreadsheet.ActiveSheet);
}
private static void ExportToPDF(IWorksheet spreadsheetControl)
{
ExcelToPdfConverter converter = new ExcelToPdfConverter(spreadsheetControl);
//Intialize the PdfDocument
PdfDocument pdfDoc = new PdfDocument();
//Intialize the ExcelToPdfConverter Settings
ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();
settings.LayoutOptions = LayoutOptions.NoScaling;
//Assign the PdfDocument to the templateDocument property of ExcelToPdfConverterSettings
settings.TemplateDocument = pdfDoc;
settings.DisplayGridLines = GridLinesDisplayStyle.Invisible;
//Convert Excel Document into PDF document
pdfDoc = converter.Convert(settings);
//Save the PDF file
pdfDoc.Save("Sample.pdf");
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo("Sample.pdf");
info.UseShellExecute = true;
System.Diagnostics.Process.Start(info);
} |