c# - OleDbConnection. How to determine is it HTML (Web Page) document or Excel document -


i have program, parses excel documents , binds gridview in asp.net using oledbconnection.

connectionstring = string.format("provider=microsoft.ace.oledb.12.0;data source={0};extended properties=\"excel 12.0; hdr=no;\";", filepath); 

also has option parse web page oledbconnection, in case import document web page throws exception "external table not in right format" or kind of.

connectionstring = string.format("provider=microsoft.ace.oledb.12.0;data source={0};extended properties=\"html import; imex=1;\";", filepath); 

this connection string web page. if try parse excel document provide same exception (see above).

so how determine type of file get, when of them have same extension (.xls or .xlsx)? in first case use 1 connection string, in second case - connection string.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -