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 8770279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:31:47+00:00 2026-06-13T17:31:47+00:00

I am trying to create a program with C++/CLI that reads some data from

  • 0

I am trying to create a program with C++/CLI that reads some data from Excel workbooks using Visual Studio.
I have added Microsoft.Office.Interop.Excel (v12) to the references in the project properties.
My basic goal would be only to get a cell’s value as a string (the workbook contains only text values).
My current code is the following (only the main part is included of course):

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace Microsoft::Office::Interop::Excel;

start(void){
        Microsoft::Office::Interop::Excel::Application^ exApp= gcnew Microsoft::Office::Interop::Excel::ApplicationClass();
        String^ filename="e:\\test.xls";
        Workbook^ wb = exApp->Workbooks->Open(filename, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing);
        Worksheet^  exWs  = safe_cast<Worksheet^>(exApp->ActiveSheet);
        int row=1;
        int col=1;
        String^ tmp=((Microsoft::Office::Interop::Excel::Range^)exWs->Cells[(System::Object^)row, (System::Object^)col])->Value2->ToString();
        MessageBox::Show(tmp);
}

When I run it, it crashes with the following error:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in exc2.exe

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

It happens with both xls and xlsx files, when I try to open the workbook (at the line that starts with “Workbook^ wb = exApp->Workbooks->Open” – so I could not even check if the rest is working).
Could some help please, what do i miss/do wrong?

Thank you in advance.

  • 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-06-13T17:31:48+00:00Added an answer on June 13, 2026 at 5:31 pm

    Okay, i got the main problem finally, if anybody else runs into the same problem:

    When opening an Excel file, the Windows’ and the installed Excel program’s regional settings have to be the same. I live in Hungary, with Hungarian regional settings in Windows [note: i use English Windows, just the regional settings differ], and I have an English version of Excel. Once I switched the regional settings in Windows to US [the same as the Excel’s region], cleaned and rebuilt the solution, everything started to work like a charm.

    (I’m not sure if the messagebox part worked in my code, i changed it meanwhile, the main problem was opening the file)

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

Sidebar

Related Questions

I am trying to create a program that will get data directly from socket
I am trying to create a program that will be passed input data from
I'm trying to create a program, which reads CSV files from a directory, using
I am trying to create a program that reads multiple choice answers from a
I am trying to create a program that will do some simple calculations, but
I'm trying to create a python program (using pyUNO ) to make some changes
I Am Trying to create a program using c# that needs to connect to
I'm trying to create a program that reads a .docx file and posts it
I am trying to create a program that calls another process using CreateProcess. After
I'm trying to create a program that reads this text file with a list

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.