Note that there are some explanatory texts on larger screens.

plurals
  1. POexport data in datagridview to excel sheet windows form
    text
    copied!<p>I have <code>DataGridView</code> and when I display export to excel sheet button following error appeared:</p> <pre><code>(Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))) here ( xlWorkBook = xlApp.Workbooks.Add(misValue); ) </code></pre> <p>and this reference which I used (Microsoft excel 12.0)</p> <pre><code> private void button1_Click(object sender, EventArgs e) { Microsoft.Office.Interop.Excel.Application xlApp ; Microsoft.Office.Interop.Excel.Workbook xlWorkBook ; Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet ; object misValue = System.Reflection.Missing.Value; xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); xlWorkBook = xlApp.Workbooks.Add(misValue); xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); int i = 0; int j = 0; for (i = 0; i &lt;= DGData.RowCount - 1; i++) { for (j = 0; j &lt;= DGData.ColumnCount - 1; j++) { DataGridViewCell cell = DGData[j, i]; xlWorkSheet.Cells[i + 1, j + 1] = cell.Value; } } xlWorkBook.SaveAs("csharp.net-informations.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.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 c:\\csharp.net-informations.xls"); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload