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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:47:39+00:00 2026-05-25T13:47:39+00:00

Error: Cannot convert type ‘string’ to ‘object[*,*]’ That’s the error I have been getting.

  • 0

Error:

Cannot convert type 'string' to 'object[*,*]'

That’s the error I have been getting. Can someone give me some pointers so that I can avoid it? Thanks.

Note:

Interestingly, (object[,])range.get_Value(XL.XlRangeValueDataType.xlRangeValueDefault)

will only produce this bug when range.Count == 1. It works fine when count is equal to and above 2.

sample code:

object[,] arrValue;  //global variable

private string[] createFormulaCollection()
        {
            ArrayList s = new ArrayList();
            try
            {
                //look at the currently active excel sheet
                //iterate through cells (not Null) and find the one contains IES(...)
                //save it into the arraylist
                //use dictionary to save position and value (position as key)
                workbook = Globals.ThisAddIn.Application.ActiveWorkbook;
                worksheet = Globals.ThisAddIn.Application.ActiveSheet;
                range = worksheet.UsedRange;

                MessageBox.Show(range.Count.ToString());


                if (range.Count > 1)
                {
                    //need to make sure there are at least 2 "ies" cells before converting to object[,]
                    arrValue = (object[,])range.get_Value(XL.XlRangeValueDataType.xlRangeValueDefault); 
                }
                else
                {
                    arrValue[1,1] = range.get_Value(XL.XlRangeValueDataType.xlRangeValueDefault); //my try here. seems still got problem though.
                }


            catch (Exception ex)
            {

            }
            return (string[])s.ToArray(typeof(string));
        }
  • 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-25T13:47:40+00:00Added an answer on May 25, 2026 at 1:47 pm

    Finding:

    range.get_Value(XL.XlRangeValueDataType.xlRangeValueDefault); will return a string when range.Count == 1
    which means it can’t be converted to object[,] type.

    it can, however, when range.Count > 1.

    My workaround:

    Just deal with it separately. So in my case I had to first count the number of range object and process them accordingly.

    if(range.Count > 1)
    {
        //code...
    }
    else
    {
        string singleStrValue = range.get_Value(XL.XlRangeValueDataType.xlRangeValueDefault);
        int iRow, iCol;
        iRow = range.Row;
        iCol = range.Column;
        if (!string.IsNullOrEmpty(singleStrValue))
        {
            //code...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting this error: cannot implicitly convert type 'string' to 'System.Data.SqlClient.Sqlconnection' for this
The following code throws an compile-time error like Cannot convert type 'string' to 'int'
I'm getting the following compiler error Cannot convert type 'T' to 'ProjectReportingHandler' for the
I am getting the following error: Cannot implicitly convert type IValueProvider to IDictionary When
Error Cannot implicitly convert type 'string[]' to 'System.Collections.Generic.List<string>' The above error is caused when
I am learning C# and keep getting an error Cannot implicitly convert type 'int'
I am getting the error Cannot implicitly convert type 'int' to 'byte'. An explicit
The following line gives an error (cannot convert type string to System.Guid) userId =
I'm receiving this error in my Linq statement --- Cannot implicitly convert type 'System.Collections.Generic.IEnumerable'
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to

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.