Click here to Skip to main content
15,792,870 members
Please Sign up or sign in to vote.
1.67/5 (2 votes)
See more:
I need to read a XLS file in C# console application and display in a grid! its better to use ExcelDataReader v2.1 library.
Please help!
Use a dummy Excel File and a dummy database if neeeded.
THis is whats done so far!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel;
using System.IO;
using System.Data;

namespace ConsoleApplication8
    class Program
        static void Main(string[] args)
            FileStream stream = File.Open(@"c:\users\afshandc\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Test Excel File.xlsx", FileMode.Open, FileAccess.Read);


            IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

            DataSet result = excelReader.AsDataSet();
           while (excelReader.Read())



Updated 22-Jul-13 23:36pm
Pheonyx 23-Jul-13 3:15am    
What have you tried so far? What issues are you having? You can't realistically expect someone to do your work for you can you?!
If that is what you want I suggest you try a freelance site.
Hawkeye101 23-Jul-13 3:19am    
I didnt Except anyone to do my work! I did it using OLEDB but cannot get it done with this!
Pheonyx 23-Jul-13 3:25am    
We are not psychic, we cannot see you screen or know what you have tried. Look at the question you posted and you should be able to see why it comes across as if you have not tried anything. You say you cannot get it done with this, well where are you getting stuck? You must be at a specific point if you have tried something. Try ridoy's and if you are still stuck use "improve Question" to add more details, such as concise snippets of code that show what you are doing, so that people have somewhere to start from with regards to helping you with your issue.
Hawkeye101 23-Jul-13 3:27am    
Alright Sorry! Ill edit the question
Hawkeye101 23-Jul-13 3:57am    
Any help??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900