Hi all,
Im trying to export my datatable to an excel.xlsx file. It doesnt seem like my dataset is getting any data so it wont copy to the excell file. I was wondering if there is a better way of doing this and overcoming this problem?
iv included my code that im using at the moment:
private void button3_Click(object sender, EventArgs e) { try { string PathConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" + textBox1.Text + ";Extended Properties =\"Excel 12.0;HDR=Yes;ImportMixedTypes=Text;\";"; conn = new OleDbConnection(PathConn); mydataAdapter = new OleDbDataAdapter("Select Rw,Type,FireRessist,SystemName from [Sheet1$]", conn); dt = new DataTable(); mydataAdapter.Fill(dt); dataGridView1.DataSource = dt; conn.Close(); DataSet ds = new DataSet("New_DataTable"); ds.Locale = System.Threading.Thread.CurrentThread.CurrentCulture; mydataAdapter.Fill(dt); ds.Tables.Add(dt); ExcelLibrary.DataSetHelper.CreateWorkbook("MyExcelFile.xlsx", ds);
Any help please !!
Ky_EX