Using stream reader to get Excel data. Almost works -- but data read comes out as gobblygook.
Posted on 2007-03-29
Using my Visual C# Sharp 2005 Express Edition....
I am trying to read an Excel file so i can save it to a database. for now, I'm just trying to get the connection to work and see that I am reading the data properly. I don't really know what I'm doing, so I ask that if you answer with some specifics. Here is my code. The results I get are some gibberish in the textbox. Please don't suggest some other methods or using some other software or database or anything. i've been running around in circle with answers like that for about a week now. I just need something simple to get the excel data into my SQL server. This is really, really close since I DO know how to add/delete/modify my SQL data. If only I could just get some data to add! Any suggestions?
public partial class Form1 : Form
private void button2_Click(object sender, EventArgs e)
System.IO.StreamReader FReader =
string str = (string) FReader.ReadToEnd().ToString();
textBox1.Text = str;