title: Export Gridview data to excel with images which is stored in database table
body: <p>i want to export gridview to excel file but the problem is that i have images in gridview which is stored in database table..by the way i storing the whole images not the path of the image and i want to export the images as well..here is the code
  but when i run this it give exceptions.. please help..
  Thank You</p>
  
  <pre><code> saveFileDialog1.Filter = "Excel (*.xls)|*.xls";
          if (saveFileDialog1.ShowDialog() == DialogResult.OK)
          {
              if (!saveFileDialog1.FileName.Equals(String.Empty))
              {
                  FileInfo f = new FileInfo(saveFileDialog1.FileName);
                  if (f.Extension.Equals(".xls"))
                  {
                      Excel.Application xlApp;
                      Excel.Workbook xlWorkBook;
                      Excel.Worksheet xlWorkSheet;
                      object misValue = System.Reflection.Missing.Value;
  
                      xlApp = new Excel.ApplicationClass();
                      xlWorkBook = xlApp.Workbooks.Add(misValue);
                      xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                      int i = 0;
                      int j = 0;
  
                      for (int h = 1; h &lt; grid.Columns.Count + 1; h++)
                      {
                          xlWorkSheet.Cells[1, h] = grid.Columns[h - 1].HeaderText;
                      }
                          for (i = 0; i &lt;= grid.RowCount - 1; i++)
                          {
                              for (j = 0; j &lt;= grid.ColumnCount - 1; j++)
                              {
  
                                  DataGridViewCell cell = grid[j, i];
                                  xlWorkSheet.Cells.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                                  xlWorkSheet.Columns.AutoFit();
                                  xlWorkSheet.Cells[i + 2, j + 1] = cell.FormatedValue;
  
  
                              }
                          }
  
                      xlWorkBook.SaveAs(saveFileDialog1.FileName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                      xlWorkBook.Close(true, misValue, misValue);
                      xlApp.Quit();
  
                      releaseObject(xlWorkSheet);
                      releaseObject(xlWorkBook);
                      releaseObject(xlApp);
  
                      MessageBox.Show("Excel file created , you can find the file " + saveFileDialog1.FileName);
                  }
                  else
                  {
                      MessageBox.Show("Invalid file type");
                  }
              }
              else
              {
                  MessageBox.Show("You did pick a location " +
                                  "to save file to");
              }
          }
  </code></pre>
  
  <p>Here is the picture of excel sheet but in the picture column pictures doesn't show up but the text "System.drawing.bitmap"
  <img src="https://i.stack.imgur.com/Pbxm5.jpg" alt="Excel sheet"></p>