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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:15:43+00:00 2026-06-10T10:15:43+00:00

I have an excel file that has ~10 columns and 1-20 rows. I need

  • 0

I have an excel file that has ~10 columns and 1-20 rows. I need to insert 1-20 rows with various data elements.

I was wondering if there was a way I could put some tags in the excel file so they could be found and replaced. Something that marks a column as “Name”. That way in code I could just say:

Name[0] = object.name;

I’m not sure if this exact method is possible, but I really don’t need any heavy lifting and I rather not hard code the cell locations as the excel file might change over time.

I will also have to add a hidden ‘ID’ cell in row. I imagine I can cross that bridge later though.

  • 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-10T10:15:45+00:00Added an answer on June 10, 2026 at 10:15 am

    Using ADO.NET is easy to add a row to an Excel Sheet

    string fileName = @"D:\test.xlsx"; 
    string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;" + 
            "Data Source={0};Extended Properties='Excel 12.0;HDR=YES;IMEX=0'", fileName); 
    
    using(OleDbConnection cn = new OleDbConnection(connectionString))
    {
        cn.Open();
        OleDbCommand cmd1 = new OleDbCommand("INSERT INTO [Sheet1$] " + 
             "([Column1],[Column2],[Column3],[Column4]) " + 
             "VALUES(@value1, @value2, @value3, @value4)", cn);
       cmd1.Parameters.AddWithValue("@value1", "Key1");
       cmd1.Parameters.AddWithValue("@value2", "Sample1");
       cmd1.Parameters.AddWithValue("@value3", 1);
       cmd1.Parameters.AddWithValue("@value4", 9);
       cmd1.ExecuteNonQuery();
    }
    

    The code above assumes that you have a first row with an header with Column1… as column names.
    Also, the code use the ACE OleDB provider for Excel 2007 or 2010 instead of Microsoft.Jet.OleDb.4.0.

    EDIT: To refer to a Named Range you could change the sql command to this one

        OleDbCommand cmd1 = new OleDbCommand("INSERT INTO [yourNamedRange] " + 
                            "VALUES(@value1, @value2, @value3, @value4)", cn);
    

    Alas, I can’t find a way to refer to the individual columns.

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

Sidebar

Related Questions

I have an Excel file that has columns A and B, both have data
I have an Excel file that gets external data from database table. I need
I have an excel file that contain columns of data, my target is to
I have an excel file that I need to make some changes. I need
I have an Excel file that I need to import into a (new) Oracle
I have an excel file (that I use as a template) with two rows.
I have an excel file that has a column that contains a number of
I have an Excel worksheet that has 30k+ rows. I'd like to cut the
I have a large CSV data file -- ~1,444,000 rows of data -- that
I have a flat file source from Excel that has a structure like this:

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.