on 11-03-2008 3:32 PM
hi everybody,
i wrote this code for finding null value while uploading data from excel sheet,but i this is not working, i am unable to find the null or empty value,can anybody help me
switch(column){
case 0 :String strNo = cell.toString(); int cellno0 = cell.getCellNum(); if(column == 0 && cellno0 == 0 && strNo != null && strNo.equalsIgnoreCase("") ){
studEle.setNo(strNo);
column++;break; }
else{
// studEle.setNo(strNo);
// column++;break; }
case 1 :String strName = cell.toString();
int cellno1 = cell.getCellNum(); if(column == 1 && cellno1 == 1 && strName != null && strName.equalsIgnoreCase("")){
studEle.setName(strName);
column++;break; }
else{
// studEle.setName(strName);
// column++;break;
}
case 2 :String strSec = cell.toString();
int cellno2 = cell.getCellNum();
if(column == 2 && cellno2 == 2 && strSec !=null && strSec.equalsIgnoreCase("")){
studEle.setSection(strSec);
column++;break;
}
else{
// studEle.setSection(strSec);
// column++;break;
}
case 3 :String strTeach = cell.toString();
int cellno3 = cell.getCellNum();
if(column == 3 && cellno3 == 3 && strTeach != null && strTeach.equalsIgnoreCase("")){
studEle.setTeacher(strTeach);
column++;break;
}
else{
// studEle.setTeacher(strTeach);
// column++;break;
}
default:wdComponentAPI.getMessageManager().reportSuccess("Data not formatted");
}
}excelList.add(studEle);
thanks®ards
murthy
hi Alka,
Thanks for your reply, now i am using different way but may be in future i will have to follow your way , if it is working fine definitily i will give you some points.
thanks®ards
Murthy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Considering the following code snippet used by you:
>
> case 0 :String strNo = cell.toString();
> int cellno0 = cell.getCellNum();
> if(column == 0 && cellno0 == 0 && strNo != null && strNo.equalsIgnoreCase("") ){
>
Following are some suggestions:
1.
String strNo = cell.toString(); // if the cell value is null then this statement itself will throw out a NullPointerException
2.
&& strNo.equalsIgnoreCase("")
i think it shoud be as:
&& !strNo.equalsIgnoreCase("")
.
3.break should be outside the if statement block.
Hence, the code should be as:
case 0:
if(cell != null && !cell.toString().equals(""))
{
studEle.setNo(cell.toString());
column++;
}
break;
Regards,
Alka.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
I changed my coding which you send,but problem is same.
pls you understand the problem,
assume it i have 4 columns with some data in wd table
No Name Student Teacher
1 ss ss sd
2 pp pp mm
3 mm mm qa
if suppose i put empty value in any cell then automatically the next cell value will replace with in this cell like below
No Name Student Teacher
1 ss ss sd
2 pp mm
3 mm mm qa
i am unable to find and put some value in empty cell.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.