How to read Excel in Mac using C# -
i wonder how can read excel file c# code in mac.
generally cannot use microsoft excel in mac. tried converting excel .csv , read same.
is there alternate this? better approach help
thanks in advance
i think, can use exceldatareader library
it's cross-platform library.
short sample github:
filestream stream = file.open(filepath, filemode.open, fileaccess.read); //1. reading binary excel file ('97-2003 format; *.xls) iexceldatareader excelreader = excelreaderfactory.createbinaryreader(stream); //2. reading openxml excel file (2007 format; *.xlsx) iexceldatareader excelreader = excelreaderfactory.createopenxmlreader(stream); //3. dataset - result of each spreadsheet created in result.tables dataset result = excelreader.asdataset(); //4. dataset - create column names first row excelreader.isfirstrowascolumnnames = true; dataset result = excelreader.asdataset(); //5. data reader methods while (excelreader.read()) { //excelreader.getint32(0); } //6. free resources (iexceldatareader idisposable) excelreader.close();
Comments
Post a Comment