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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:06:58+00:00 2026-06-06T03:06:58+00:00

below is the code i’m using and i’ve used this 100x’s before. And now

  • 0

below is the code i’m using and i’ve used this 100x’s before. And now it’s throwing an error, basically i’m trying to dynamically create the Columns based on the first row of an excel file. The error that i’m receiving now is:

The call is ambiguous between the following methods or properties: 'System.Data.DataColumnCollection.Add(System.Data.DataColumn)' and 'System.Data.DataColumnCollection.Add(string)'

DataTable excel_Holding_Table = new DataTable();
        DataRow row;
        Microsoft.Office.Interop.Excel.Range range = workSheet.UsedRange;
        for (int i = 1; i <= range.Columns.Count; i++)
        {
            excel_Holding_Table.Columns.Add(Convert.ToString(((Microsoft.Office.Interop.Excel.Range)workSheet.Cells[1, i]).Value2));
        }

What do I need to do to prevent this from happening, this has never appeared.

here is my using:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
  • 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-06T03:06:59+00:00Added an answer on June 6, 2026 at 3:06 am

    My guess is that Convert.ToString is returning null, but because you’re calling Add dynamically, it can’t work out the overload based on the actual type.

    Fortunately, we can improve the code’s readability and fix the problem at the same time:

    for (int i = 1; i <= range.Columns.Count; i++)
    {
         // Note: Add using directive for Microsoft.Office.Interop.Excel
         Range range = (Range) workSheet.Cells[1, i];
         string value = Convert.ToString(range.Value2);
         excel_Holding_Table.Columns.Add(value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below code gives this error message Specified method is not supported. But here is
The below code gives the error The operator 'expr.[idx]' has been used an object
Below code is to create imageviews dynamically and add to its parent layout on
Below code saying error incorreect syntax near Main INSERT INTO tbl ( 'Week', Main,
My below code works fine and is used to populate a <select> item with
Below code is working properly now. But if I replace 'text.txt' with ' http://google.com
Below is code used to search a string where Identity= exists and stores that
Below code gives Too much recursion error in Jquery ui dialog $( #dialog-confirm ).dialog({
Below code is not working in IE but working in Chrome... $(this).css(border,solid 1px green)
Below code is validating properly.When i first submit the form,it shows the error message,second

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.