java - Getting null while reading Hyperlink from excel using poi -
i have 1 excel file in row contains few cell string , other numeric, hyperlink.
i want read data excel wrote below code
hssfcell cell =row.getcell(j+1); cell.setcelltype(celltype.string); string cellvalue = cell.getstringcellvalue();
above code reads numeric cells , string cells when comes cells contain hyperlink, in case, reading cells null.i can put hyperlink between double quotes("abc@cd.com") in sheet want handle on code level. there way handle scenario?
you should use cell.gethyperlink() hyperlink cell.
if(cell.getcelltypeenum() == celltype.string){ hyperlink hyperlink = cell.gethyperlink(); string value = cell.getrichstringcellvalue().getstring(); if(hyperlink == null) { return value; } else { return value + " " + hyperlink.getaddress(); } }
Comments
Post a Comment