title: Export DataGridView Data with Images into Excel, HTML, or Word with Proper Table Formatting
body: <p>I have a data grid view with images loaded into it.  The table which is the source for this data grid has path for images and I load images using that path.  I have tried to export data to Excel and was successful, but it seems to show some problems with images.  Please any help?  Any help instead of Excel, HTML, or Word or anything would do, but please provide detailed help or it causes a lot of problems.</p>
  
  <p>Here is the code I used to export to Excel:</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 (i = 0; i &lt;= dataGridView1.RowCount - 1; i++)
                          {
                              for (j = 0; j &lt;= dataGridView1.ColumnCount - 1; j++)
                              {
  
                                  DataGridViewCell cell = dataGridView1[j, i];
                                  xlWorkSheet.Cells.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                                  xlWorkSheet.Columns.AutoFit();
                                  if (cell.Value.GetType() == typeof(Bitmap))
                                  {
                                      xlWorkSheet.Cells[i + 1, j + 1] = ReadFile((Bitmap)cell.Value);
                                  }
                                  else
                                  {
                                      xlWorkSheet.Cells[i + 1, j + 1] = cell.Value;
                                  }
  
                              }
                          }
  
                          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>Table format is:</p>
  
  <p>ax_no
  rm_no
  fullName
  Types
  photograph // path of file.
  Fingerprint // path of file.</p>
  
  <p>All are strings.  I have also tried using Spire.dataExport and iTextSharp but it doesn't work.</p>