Been having truble with data tables. What i want do to is to take out a colum from an Excel document and later use it for creating a PDF file.
here is the code where i take out the data and puts in a Datagrid view.
void ExcelOpen()
{
string PathConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +textBox1.Text+ ";Extended Properties=Excel 12.0;";
OleDbConnection conn = new OleDbConnection(PathConn);
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter("SELECT * FROM[" + textBox3.Text + "$"+Kolumn1.Text+":"+Kolumn1.Text+"]", conn);
DataTable dt = new DataTable();
myDataAdapter.Fill(dt);
dataGridView1.DataSource = dt;
// a try to convert the data to an Array.
List<String> str = new List<string>();
foreach (DataRow row in dt.Rows)
{
foreach (DataColumn col in dt.Columns)
{
stringColumnValue +="" + Convert.ToString(row[col]);
}
str.Add(stringColumnValue.Trim());
}
string.Join(" ", str.ToArray());
}