Validating an Excel files contents client side through an ASP.NET web app

Bruce
Bruce used Ask the Experts™
on
I have a client that is asking for an Excel file to be "validated" before (client side) it is uploaded to the server through an ASP.NET web app.  The validation would consist of checking for a number of columns and then checking that the values in each of the rows for each column meets spec.

Is it possible to open a excel file on the client side and check its contents?

I'm guessing not.  The only thing I could come up with is possible an ActiveX control on a page that the client would "allow" to access the local file and perform the validations through that control.  
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Sure it is possible - but the best bet would be serverside, since activex controls or add-ons might not be installed on the browser of the client.

A serverswide validation would consist of:
step 1) upload the file
step 2) save the file to a protected server folder
step 3) use an OleDbConnection with an excel file connectionstring (Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1")
step 4) query the excel file and use a try - catch method to catch for the validity of the file.

Make sure the excel provider is present pn the server.

Cheers
CJ.

Author

Commented:
Thanks CJ S!

One of my co-workers found this...

http://support.microsoft.com/kb/198703/

I'm not worried about keeping the code/validations secret/private so the VBScript will work.

Commented:
That solution will work as well, but it is written in ASP. There is probably also a version of it for ASP.Net, but it will require you to install Excel or it's API on the server. Obiously it usually doesn't sit there.
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Author

Commented:
CJ S,

Good information.  I didn't think about that.

Author

Commented:
CJ S,

Question: wouldn't the script try to instantiate the that object on the client side as the script would be running in the browser?

Commented:
Indeed it will - I missed that it was the clientside version.

You do know that it will only work on clients who
1) have installed Excel
2) use Internet Explorer
3) allow VBScript
4) allows to run the application

Author

Commented:
No problem...

Yes on all questions.  These are all requirements for systems that are already in place for these clients.

Thanks CJ S.  Appreciate the quick response.

Commented:
Np - glad to help.

Cheers,
CJ.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial