Export current sheet

Hi,


I have for example a 30 sheets in my workbook. And I would like to export or save only the active sheet. How to do that?


1 Reply

SS Sampathnarayanan Sankaralingam Syncfusion Team December 29, 2021 10:08 AM UTC

Hi Mark, 
 
You can achieve your requirement through following code snippet. 
 
Code Snippet : 

 
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); 
} 

 
Regards, 
Sampath Narayanan.S 


Loader.
Up arrow icon