Published on: 10 March, 2015

How to read excel workbook using open source .Net Koogra

Posted by andy | 2497 views 2 likes 0 favourites 0 comments
Tumblr Digg Google Plus

Learn how easy to read excel file using open source .Net Koogra. This library can only used to read excel, biff and xlsx files.

Firstly download the library dll file and copy the file into the bin folder.

Secondly, use the using import method and place this at the top of your code.

using Net.SourceForge.Koogra;

This is the example of routine to read the excel file. Make sure the path of your excel file is correctly defined.

private void ReadExcel(){
	string fullPath = Server.MapPath(Globals.ApplicationPath + "/sample.xls");
	xlsObject = ExcelOpenSpreadsheet(fullPath, 0);
	for (int i = 0; i < xlsObject.Count(); i++){
		object[] row = xlsObject[(int)i];
		if (row[0] != null && i >= 0){
			Response.Write("Value is for column 0 on row " + i.ToString() + " is " + row[0].ToString());
private object[][] ExcelOpenSpreadsheet(string thisFileName, int worksheetID){
	object[][] values = null;
		xlFile = Net.SourceForge.Koogra.WorkbookFactory.GetExcelBIFFReader(thisFileName);
		sheet = xlFile.Worksheets.GetWorksheetByIndex(worksheetID);
		values = new object[sheet.LastRow + 1][];
		uint r = 0;
		uint c = 0;

		for (r = sheet.FirstRow; r <= sheet.LastRow; r++){
			values[r] = new object[8];
			Net.SourceForge.Koogra.IRow row = sheet.Rows.GetRow(r);
			if (row != null)
				for (c = 0; c < 8; c++)
					if (row.GetCell(c) != null)
						values[r][c] = row.GetCell(c).Value;
	}catch (Exception ex){
	return values;

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.
Related Articles
Published on: 13 February, 2017
One thing to remember when publishing your ASP.Net web applications, you may find out, some files could be not completely published due to the settings on the file properties. One example that I had are some font types file. In order to fix this problem you can navigate to the files that are missing and right click the properties.
Published on: 11 May, 2016
The slidingExpiration attribute is used in ASP.Net form authentication. This property is used to reset the expiration time for a valid authentication cookie if a request that has already being made has passed the timeout interval. Which means, if it is already expires, the current user will require to re-authentication again.
Related Tutorials