C#-MSTest-Excel Data Driven of .xlsb and .xlsb files using the Data Source issues

vadivel sekar 1 Reputation point
2021-09-09T16:07:45.14+00:00

Hi,

When the '.xlsb' file is being data driven/read, an additional empty row is being executed or stored and the character "d" is randomly generated.

public class DataDriven
{

    private TestContext _testContext;  

    public TestContext TestContext  

    {  

        get { return _testContext; }  

        set { _testContext = value; }  

     }          

    [TestMethod]  

    [DataSource("System.Data.Odbc", @"Dsn=Excel Files;dbq=CreateBugXlxs.xlsx", "CreateBug$", DataAccessMethod.Sequential)]  

    public void TestDataDriven()  

    {  

        Console.WriteLine(TestContext.DataRow[0].ToString());  

        Console.WriteLine(TestContext.DataRow[1].ToString());  

        Console.WriteLine(TestContext.DataRow[2].ToString());  

        Console.WriteLine(TestContext.DataRow[3].ToString());  

        Console.WriteLine(TestContext.DataRow[4].ToString());  

}

Screenshots:
Issue Reference:
130727-excel-datadriven-xlsb-issue.png

Working Reference:
130823-excel-datadriven-xlsx-ref.png

Update to the issue:

Added a new sheet such as "Sheet1" and when the below code is executed the warning is displayed without any details and data reading is unsuccessful.

Please Note: The issue occurs in ".xlsx" and ".xlsb" files

Code:

[TestClass]
public class TestCreateBugXlxs
{
private TestContext _testContext;

    public TestContext TestContext  
    {  
        get { return _testContext; }  
        set { _testContext = value; }  
    }  

      
    [TestMethod]  
    [DataSource("System.Data.Odbc", @"Dsn=Excel Files;dbq=TestCreateBugXlsb.xlsb", "Sheet1$", DataAccessMethod.Sequential)]  
    public void TestBugXlxs()  
    {  
        Console.WriteLine(TestContext.DataRow[0].ToString());  
     }  

}

130893-excel-datadriven-xlsb-issue1.png

Developer technologies | Visual Studio | Testing
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2021-09-10T13:05:16.213+00:00

    Hi @vadivel sekar ,

    Welcome to Microsoft Q&A!

    You can have a try with the following code and check if the same situation exists or not:

     Console.WriteLine(TestContext.DataRow[“Severity”].ToString());       
     Console.WriteLine(TestContext.DataRow[“Hardware”].ToString());  
     Console.WriteLine(TestContext.DataRow[“OS”].ToString());  
     Console.WriteLine(TestContext.DataRow[“Summary”].ToString());  
     Console.WriteLine(TestContext.DataRow[“Description”].ToString());  
    

    Besides, about the character “d” is randomly generated, I suggest you report it in Developer Community.

    Sincerely,
    Anna

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.