How to convert the WinForms DataGrid to Image?
WinForms DataGrid (SfDataGrid) can be exported into Excel and PDF files. It also possible to convert the exported excel file into Image without saving the excel file in system with the help of IWorksheet.ConvertToImage method.
using Syncfusion.WinForms.DataGridConverter;
using Syncfusion.XlsIO;
private void BtnExportExcel_Click(object sender, EventArgs e)
{
var excelExportingOptions = new ExcelExportingOptions();
var excelEngine = sfDataGrid.ExportToExcel(sfDataGrid.View, excelExportingOptions);
IWorkbook workbook = excelEngine.Excel.Workbooks[0];
IWorksheet sheet = workbook.Worksheets[0];
sheet.UsedRangeIncludesFormatting = false;
int lastRow = sheet.UsedRange.LastRow + 1;
int lastColumn = sheet.UsedRange.LastColumn;
System.Drawing.Image img = sheet.ConvertToImage(1, 1, lastRow, lastColumn, ImageType.Bitmap, null);
img.Save("Sample.png", ImageFormat.Png);
System.Diagnostics.Process.Start("Sample.png");
} Note:
The following assemblies are required for converting the DataGrid to excel and image.
- Syncfusion.Compression.Base
- Syncfusion.SfDataGridConverter.WinForms
- Syncfusion.XlsIO.Base
The following screenshot shows the converted DataGrid to Image.

Take a moment to peruse the WinForms DataGrid – Export to Excel documentation, where you can find about export to excel with code examples.