|
this.sfDataGrid1.AllowEditing = false;
this.sfDataGrid1.SelectionMode = GridSelectionMode.Multiple;
this.sfDataGrid1.CellDoubleClick += SfDataGrid1_CellDoubleClick;
private void SfDataGrid1_CellDoubleClick(object sender, CellClickEventArgs e)
{
//Export to PDF
PdfExportingOptions pdfoptions = new PdfExportingOptions();
pdfoptions.AutoColumnWidth = true;
var document = sfDataGrid1.ExportToPdf(sfDataGrid1.SelectedItems, pdfoptions);
document.Save("Sample.pdf");
//Export to Excel
var exceloptions = new ExcelExportingOptions();
ExcelEngine excelEngine = new ExcelEngine();
IWorkbook workBook = excelEngine.Excel.Workbooks.Create();
workBook.Worksheets.Create();
sfDataGrid1.ExportToExcel(sfDataGrid1.SelectedItems, exceloptions, workBook.Worksheets[0]);
workBook.Version = ExcelVersion.Excel2013;
workBook.SaveAs("Sample.xlsx");
}
|