Excel Sheet Validation
I'm using an application, which uploads an excel file to the server. New Users generally download the excel sheet from my application(Excel sheet template -name,age,dept), and they fill in the data(from downloaded excel sheet - name,age,dept) and they upload the filled in excel sheet to the server.
As a part of validation, i need to find out whether the user is uploading the correct excel sheet or not.
excel sheet with 3 columns (name, age,dept). one way of identifying whether the user is uploading the correct excel sheet or not , is to read the columns ...if the uploaded excel sheet has 3 columns,(name , age, dept), then it is the correct excel sheet.
is there any other way of doing this validation? can i set some version number in the downloaded excel sheet(i.e ) excel sheet downloaded by users)and then if the uploaded excel sheet has the same version number? if not , invalid excel sheet.
If you only have the three columns, and all you want to do is check if there are three columns, just give them headers (which ist sounds like you have done) and then check the headers match. That is grab the first row and cycle through cells 1-3 (or is it 0-2, I can never remember) ensuring they aren't null and they equal the header value.
I'm not sure what else you want to ensure? If they're only allowed to upload the sheet they downloaded then you could stick a value in a second (hidden and password protected) sheet if you want, but that wouldn't prevent the user from doing whatever they wanted on the first sheet.
Thanks for your reply.
1. i can check the columns,but its not 3, but 20, i dont want to check 20 columns one by one and decide, whether it is the correct template or not.
Tomorrow, we might add one more columns, that make it 21. if the user is still using the old one(which has 20 columns), i dont want to read the header (21 columns) and decide whether it is the right one or not.
what i'm looking for is, can i set some kind of attribute or hidden value in the xlsheet to decide whether it is the right one or not?
is there a way to set a hidden value in any cell of excel sheet? or can i set any attritbue?
the idea is set the hidden value in the downloded excel sheet, if the user is using the same excel sheet, then it will have the same value when uploaded, i'll decided based on that.
any thoughts on my idea?
OK, I understand now.
Use the thing I describe in the second paragraph.
Have a field (a named field would be good, as they can be easier to find using POI/Jexcel) which contains the version number on its own sheet, and hide and password protect that sheet.
As I say, though, this won't mean they haven't mucked about with the first sheet, but at least you'll know they downloaded the correct one.