May 29, 2016 at 4:21am UTC
Hello,
I'm writing a windows form program (C++/CLI) and need a bit of guidance...
I have a dataGridView full of data which I would like to EXPORT to an excel file.
The dataGridView is actually populated using OleDB but I can't seem to figure out how to do the export.
At this stage, I'm not fussy about formatting. Just a simple copy and paste of information.
Is there anyone out there willing to provide me an example code with some explanation notes?
Cheers,
May 29, 2016 at 11:37am UTC
You forgot the provide in your connection string. Try this:
String^ connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\test.xlsx;Extended Properties=\"Excel 12.0 XML;HDR=YES\"" ;
May 29, 2016 at 11:57am UTC
Thomas1965,
Once again, you've helped me deluxe!
Yep, your correction worked fine. Now I just need to work out how to transfer what's in my dataGridView to the xlsx file.
Also, I notice that if click my export button after the file has been created, it produces this error message:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: Table 'table1' already exists.
Cheers for your help... Would you mind if I sent you a message if I get stuck?
May 29, 2016 at 2:42pm UTC
Yes you can send me a message if you want. Would be good if you could upload the project on Dropbox or sth. similar.