mardi 2 juin 2020

Getting a random cell from excel file using c#.net framework consoleApp

Getting a random cell from excel file using c#.net framework consoleApp so I tried this but it gaves me this exeption System.Runtime.InteropServices.COMException: 'Exception from HRESULT: 0x800A03EC'.

 Workbook excelBook = excelApp.Workbooks.Open(@"C:\\Projects\\ExcelSingleValue\\kTest.xlsx");
             _Worksheet excelSheet = excelBook.Sheets[1];
             Range excelRange = excelSheet.UsedRange;

             int rows = excelRange.Rows.Count;
             int cols = excelRange.Columns.Count;

             Random randomName = new Random();
             Console.WriteLine((excelRange.Cells[randomName.Next(rows),1].Value2.ToString()));
 ```



Aucun commentaire:

Enregistrer un commentaire