Read Excel sheet using ADO on Visual C++
We have an old application written using VC++ that uses ODBC driver to read the excel data.
There are problems in current code with mixed data type and li开发者_C百科mitations of ODBC driver.
SO I am planning to use Jet OLE DB driver and use ADO
The code I have opens ADO connection and reads excel sheet.No issues here..
The biggest problem is everytime, Open() is called, it brings up the Excel sheet and displays to the user (if it is not already open). I tried to look into the parameters, but did not find any suggestions to hide main excel window.
Any suggestions?
The connection string I am using is
Provider='Microsoft.JET.OLEDB.4.0';Data Source=temp.xls;Extended Properties="Excel 8.0;IMEX=1;HDR=NO"
Three options spring to mind:
- Use Automation to open the spreadsheet in a hidden window. I.e. you can create an instance of the Excel application, hide the main window, and open the spreadsheet in that window.
- Use the ISAM driver instead of the JET driver. That may change the behaviour in undesirable ways though.
- Live with it.
精彩评论