コード例 #1
0
        public void TestReadExcel()
        {
            //FileStream stream = new FileStream(@"D:\Git\SeleniumWebdriver\DataFiles\Data.xlsx", FileMode.Open, FileAccess.Read);
            //IExcelDataReader reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
            //DataTable table = reader.AsDataSet().Tables["Bugzilla"];
            //for (int i = 0; i < table.Rows.Count; i++)
            //{
            //    for (int j = 0; j < table.Rows[i].ItemArray.Length; j++)
            //    {
            //        Console.WriteLine($"Data: {table.Rows[i][j]}");
            //    }
            //}
            string xlPath = @"D:\Git\SeleniumWebdriver\DataFiles\Data.xlsx";

            Console.WriteLine(ExcelReaderHelper.GetCellData(xlPath, "Bugzilla", 1, 0));
            Console.WriteLine(ExcelReaderHelper.GetCellData(xlPath, "Bugzilla", 1, 1));
            Console.WriteLine(ExcelReaderHelper.GetCellData(xlPath, "Bugzilla", 1, 2));
        }
コード例 #2
0
        public void TestReadExcel()
        {
            //FileStream stream = new FileStream(@"C:\Users\rahul.rathore\Desktop\Cucumber\Data.xlsx",FileMode.Open,FileAccess.Read);
            //IExcelDataReader reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
            //DataTable table =  reader.AsDataSet().Tables["Bugzilla"];
            //for (int i = 0; i < table.Rows.Count; i++)
            //{
            //    var col = table.Rows[i];
            //    for (int j = 0; j < col.ItemArray.Length; j++)
            //    {
            //        Console.Write("Data : {0}", col.ItemArray[j]);
            //    }
            //    Console.WriteLine();
            //}
            string xlPath = @"C:\Users\rahul.rathore\Desktop\Cucumber\Test.xlsx";

            Console.WriteLine(ExcelReaderHelper.GetCellData(xlPath, "Bugzilla", 0, 0));
            Console.WriteLine(ExcelReaderHelper.GetCellData(xlPath, "Bugzilla", 0, 1));
            Console.WriteLine(ExcelReaderHelper.GetCellData(xlPath, "Bugzilla", 0, 2));
        }