TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
paul mc gavigan
NA
5
3.3k
Read excel file and write to a jagged array?
Jan 11 2012 8:52 AM
Hi, I have been asked to write a small piece of code which will open an excel file in c# and then write said excel file to a jagged array. I had never heard of a jagged array until monday so I am pretty much at a loss here as to what I am doing. So far I have managed to open the excel file in visual studio and write the contents to a datagridview but would like to bypass this and write it directly to jagged array any help much appreciated. Here is my working code so far.
private void button1_Click(object sender, EventArgs e)
{
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='C:\\myworkbook.xlsx ';Extended Properties=Excel 12.0;";
{
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connection);
DataSet ds = new DataSet();
System.Data.DataTable dt = new System.Data.DataTable();
adapter.Fill(ds);//now you have your dataset ds now filled with the data and ready for manipulation
dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
}
any help much appreciated.
Reply
Answers (
4
)
Release Mode Debug in visual studio
Need to replace a line in an Array list