Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4055648
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:43:39+00:00 2026-05-20T14:43:39+00:00

I have DataGridView and when I display export to excel sheet button following error

  • 0

I have DataGridView and when I display export to excel sheet button following error appeared:

(Old format or invalid type library. (Exception from HRESULT: 0x80028018  (TYPE_E_INVDATAREAD)))

here
(
xlWorkBook = xlApp.Workbooks.Add(misValue);
)

and this reference which I used
(Microsoft excel 12.0)

 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 <= DGData.RowCount  - 1; i++)
        {
            for (j = 0; j <= 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");
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:43:40+00:00Added an answer on May 20, 2026 at 2:43 pm

    Error might be because the user local settings are different from the office version, the solution below might work for you, try it and let us know what happens:

    Before creating Excel object

    System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
    

    After closing Excel:

    System.Threading.Thread.CurrentThread.CurrentCulture = oldCI;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a DataGridView which is used to display a list of custom
On my main window I have a DataGridView that I wish to display my
I have a DataGridView that shows list of records and when I hit a
I have a DataGridView with cells from a database file that contains data. Basically,
I have a DataGridView bound to a DataTable in a DataSet . I set
Say I have a DataGridView (named dataGridView ) that is displaying a Strongly Typed
I have a DataGridView that is displaying a List of objects (not DataSet). Is
I have a datagridview with a number of columns, one of these is a
i have a Problem with DataGridView in c# and i hope you can help
I have classes that store data, and methods to go get data for individual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.