none
Smart Device RRS feed

All replies

  • Hi ThanhTungStyle,

    I am not completely sure what you are trying to achieve and what the real scenario is, but it might be a problem of how to connect to excel.

    There is the option to use OleDB and use the Excel sheets like datatables in a database...

    string con =
      @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\temp\test.xls;" + 
      @"Extended Properties='Excel 8.0;HDR=Yes;'";    
    using(OleDbConnection connection = new OleDbConnection(con))
    {
        connection.Open();
        OleDbCommand command = new OleDbCommand("select * from [Sheet1$]", connection); 
        using(OleDbDataReader dr = command.ExecuteReader())
        {
             while(dr.Read())
             {
                 var row1Col0 = dr[0];
                 Console.WriteLine(row1Col0);
             }
        }
    }

    If I misunderstood you, please feel free to let me know.

    Best regards,

    Kristin


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 25, 2016 1:27 AM