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

The Archive Base Latest Questions

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

I have added an Excel file to provide unit test values. Below is a

  • 0

I have added an Excel file to provide unit test values.

Below is a example about what I was doing before

public void test1()
{
    try
    {
        var Service = new Service.ServiceClient();
        var Cid = testContextInstance.DataRow["CId"].ToString();
        var MNumber = testContextInstance.DataRow["MNumber"].ToString();
        var VID = testContextInstance.DataRow["VID"].ToString();
        var isVisit = new Service.ISVisit()
        {
        };

    var first = Service.Medis(isVisit).Cast<Service.ISMedi>().FirstOrDefault();
    // Assert
    Assert.AreEqual("12345678", first.Proc.ProcID);
    }

.i am using excel sheet to provide values for the untitest.

enter image description here

By using the sample code above i am able to loop through each row in the excel and set values to the variables.But the Requirement is not to attach excel as a Data Driven Source and not to use Oledb way to query things in Excel.They said me to use Microsoft.Office.Interop.Excel; .

Can any one help me with how to change the code to retrive the data in excel , row by row and assign cells to respective variables using different approach.??? This is a c# Unittest framework

  • 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-13T07:47:10+00:00Added an answer on June 13, 2026 at 7:47 am

    See http://msdn.microsoft.com/en-us/library/office/microsoft.office.interop.excel(v=office.11).aspx.

    This might be a duplicate of the C#: How to access an Excel cell?, which has examples in the answers using Interop.

    Warning

    Because you mention webservices and Office interop in the same question:

    Microsoft does not currently recommend, and does not support,
    Automation of Microsoft Office applications from any unattended,
    non-interactive client application or component (including ASP,
    ASP.NET, DCOM, and NT Services), because Office may exhibit unstable
    behavior and/or deadlock when Office is run in this environment.

    See http://support.microsoft.com/kb/257757 for more information.

    OOXml

    If possible, you should be using OOXml, which is the recommended way to work with Office documents programmatically.

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

Sidebar

Related Questions

I am trying to read data from excel file in asp.net. I have added
I have a question about password protecting an Excel file. The situation is that,
I have a calendar table Excel file. Every month a new column is added.
I have added an HTML file to my solution in VS2010. How do you
I have added an external .exe file into my VS2010 setup project and I'd
I have an Excel file made with PHPExcel which have an header with a
I have a Word document with two embedded Excel files (added using Insert ->
I have a DLL (Test.dll) which contains some Excel Addin, i don't know which
I have a column in an excel file that contains both strings and numbers.
I'm trying to export a mysql query table to an excel file. I have

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.