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

  • SEARCH
  • Home
  • 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 7419361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:03:24+00:00 2026-05-29T08:03:24+00:00

I was using the following Code in order to export a dataset to xlsx.

  • 0

I was using the following Code in order to export a dataset to xlsx.
Everything works fine when i am on .net 4.0 but there is a server that requires the framework to be in 3.5 unfortunately and i can’t do anything about it. So i changed the framework from 4.0 to 3.5 and when i execute the code i get an error

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

the error happens when the bellow line executes

Excel.Workbook workBook = excel.Workbooks.Add();

this is my Code

static void Main(string[] args)
        {

             String filepath = "C:/test.csv";            
             DataSet ds = Convert(filepath.ToString(), "tblCustomers", "\t");            
             Excel.Application excel = new Excel.Application();           
             Excel.Workbook workBook = excel.Workbooks.Add();   
             Excel.Worksheet sheet = (Excel.Worksheet)workBook.ActiveSheet;
            int i = 0;            
                for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
                {
                    sheet.Cells[i + 1, j + 1] = ds.Tables[0].Columns[j].ToString();            
                }

                i = 1;                
            foreach (DataRow row in ds.Tables[0].Rows)
            {                              
                for (int j = 0; j < row.ItemArray.Length; j++)
                {
                    sheet.Cells[i + 1, j + 1] = row[j].ToString().Trim();
                    //cleangth = row[j].ToString().Trim().Length *10;

                }

                i++;
            }


            workBook.SaveAs(@System.IO.Directory.GetCurrentDirectory() + "\\test.xlsx");
            workBook.Close();           

        }

Any suggestions ?

  • 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-29T08:03:26+00:00Added an answer on May 29, 2026 at 8:03 am

    This apparently is a bug which was fixed in .NET 4.0 (source): if the regional setting of Excel is different from the regional setting of the PC, you will get this error.

    From Microsoft:

    You receive this error calling an Excel method when the following conditions are true:

    -The method requires an LCID (locale identifier).

    -You run an English version of Excel. However, the regional settings for the computer are configured for a non-English language.

    If the client computer runs the English version of Excel and the locale for the current user is configured for a language other than English, Excel will try to locate the language pack for the configured language. If the language pack is not found, the error is reported.

    To work around this problem, you can use one of the following methods:

    -Install the Multilingual User Interface Pack for your version of Office.

    -Execute the Excel method or property by using InvokeMember so that you can specify the CultureInfo for the call. For example, the following code illustrates how you can invoke the Workbooks object Add method with "en-US" as the CultureInfo

    -Or, set the CultureInfo prior to calling the Excel method.

    see this link for code examples of the suggested workarounds: http://support.microsoft.com/kb/320369

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using following code but cannot return data from MySQL. This is the output:
I am using the following code snippet in order to crop a image? function
I'm using the following code in order to antialias only the edges of my
Dear Folk's i'm using the following code in order to send the bytes of
I'm using the following code with the javax.swing.text.html.parser.ParserDelegator in order to parse hyperlinks from
I am using the following code in order to reverse a char array. My
In order to generate a XML i am using following Code currently. .<?php require
I'm using ODP.NET in an c# application, and i'm using the following code to
I am using the following code to get my unique order types: NSArray *orderTypes
I'm using the following code in order to make an ajax call to my

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.