This is a sample code for C# to read up an excel file and return the results in a CSV format using the Koogra library.
// This example shows how to read and excel file using the Koogra library (http://sourceforge.net/projects/koogra/) // Supports .xls and .xlsx example public static string ReadExcelContent(string filePath) { uint rowNum = 0; uint colNum = 0; var data = new StringBuilder(); try { Net.SourceForge.Koogra.IWorkbook wb; string fileExt = Path.GetExtension(filePath); if (string.IsNullOrEmpty(fileExt)) { throw new Exception("File extension not found"); } if (fileExt.Equals(".xlsx", StringComparison.OrdinalIgnoreCase)) { wb = Net.SourceForge.Koogra.WorkbookFactory.GetExcel2007Reader(filePath); } else if(fileExt.Equals(".xls", StringComparison.OrdinalIgnoreCase)) { wb = Net.SourceForge.Koogra.WorkbookFactory.GetExcelBIFFReader(filePath); } Net.SourceForge.Koogra.IWorksheet ws = wb.Worksheets.GetWorksheetByIndex(0); for (uint r = ws.FirstRow; r <= ws.LastRow; ++r) { Net.SourceForge.Koogra.IRow row = ws.Rows.GetRow(r); if (row != null) { string lineEnding; for (uint colCount = ws.FirstCol; colCount <= ws.LastCol; ++colCount) { string cellData = string.Empty; if (row.GetCell(colCount) != null && row.GetCell(colCount).Value != null) { cellData = row.GetCell(colCount).Value.ToString(); } if (colCount == ws.LastCol) lineEnding = Environment.NewLine; else lineEnding = "\t"; //tab data.Append(string.Concat(cellData, lineEnding)); } } } } catch (Exception ex) { Exception exception = ex; exception.Source = string.Format("Error occured on row {0} col {1}", rowNum, colNum); throw ex; } return data.ToString(); }