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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:50:05+00:00 2026-05-24T02:50:05+00:00

Im trying to insert RoomType array into the excel book. Range of RoomType is

  • 0

Im trying to insert RoomType array into the excel book. Range of RoomType is From D22 To D25 so problem is that this code only put the firts value In this range. if i insert RoomType.set_Value into the for loop, excel range filling with last array item. can anyone help me?

 Object[,] RoomtypeArray = new object[1, _RoomType.Count];
     for (int i = 0; i < _RoomType.Count; i++)
                {
                    RoomtypeArray[0, i] = _RoomType[i];

                }
 RoomType.set_Value(Type.Missing, RoomtypeArray);
  • 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-24T02:50:06+00:00Added an answer on May 24, 2026 at 2:50 am

    This is what you need:

    //Microsoft.Office.Interop.Excel.Range RoomType;
    //List<double> _RoomType;
    
    object[,] roomTypeArray = Array.CreateInstance(
        typeof(object),
        new int[] { 1, _RoomType.Count},
        new int[] { 1, 1 });
    
    for (int i = 0; i < _RoomType.Count; i++)
    {
        roomTypeArray[1, i + 1] = _RoomType[i];
    }
    
    RoomType.Value2 = roomTypeArray;
    

    because setting an array for a range requires 1-based indexes instead of 0-based which are used with the new statment in C#.

    (look also in the accepted answer of How can I quickly up-cast object[,] into double[,]? to find a neat trick going between object[,] and double[,] for use in Excel Inerop).

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

Sidebar

Related Questions

I have code from my ad network that I am trying insert into an
In the below code, I am trying insert the records from excel to Database
I'm trying to insert values into a SQL database from within Java. This works
im trying to insert this query with mysql_query INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,1,1)
I am trying to INSERT INTO a table using the input from another table.
I'm trying to insert a comment character into a string something similar to this:
This is the query I am trying: INSERT INTO Product (ProductName, Description, Brand, Size,
Im trying to insert data into a table in MySQL. I found/modified some code
I am trying to insert rows of data in an array into a table.
I'm trying to insert some symbols from LaTeX Math Symbols into my LaTeX document:

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.