I am trying to read data from an excel file.
FileStream stream = File.Open (@"C:\Temp\F1\SMRPAC974-00024COMINVDETEXTRACT.xlsx", FileMode.Open, FileAccess.Read); IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); DataSet result = excelReader.AsDataSet(); excelReader.Close(); string csvData = ""; int row_no = 0; while (row_no < result.Tables[0].Rows.Count) { for (int i = 0; i < result.Tables[0].Columns.Count; i++) { csvData += result.Tables[0].Rows[row_no][i].ToString() + ";"; } row_no++; csvData += "\n"; }
The problem that I am currently facing is an error that "Cannot find the central directory." I do not know what this means that I even tried to move the excel file to different locations, but I still encounter the same error.
c #
Thebells
source share