本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFCell.toString方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFCell.toString方法的具体用法?Java HSSFCell.toString怎么用?Java HSSFCell.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.hssf.usermodel.HSSFCell
的用法示例。
在下文中一共展示了HSSFCell.toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeUserNum
import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
/**
* 修改用户继教号
* @return
*/
public String changeUserNum(){
try{
InputStream templatInputStream = this.getClass().getResourceAsStream("/com/opendata/organiz/action/teacher.xls");
BufferedInputStream in = new BufferedInputStream(templatInputStream);
POIFSFileSystem fs = new POIFSFileSystem(in);
HSSFWorkbook book=new HSSFWorkbook(fs);
HSSFSheet sheet = book.getSheetAt(0);
int num = sheet.getLastRowNum();
List<Map<String ,String>> l = new ArrayList<Map<String,String>>();
for(int i=1;i<num;i++){
HSSFRow row = sheet.getRow(i);
HSSFCell c1 = row.getCell(1);
if(c1!=null){
//继教号
String userNum = c1.toString();
HSSFCell c5 = row.getCell(5);
if(c5!=null){
//身份证号
String IDNum = c5.toString();
Map<String ,String> map = new HashMap<String,String>();
map.put("userNum", userNum);
map.put("IDNum", IDNum);
l.add(map);
}
}
}
userManager.batchUpdateUserNum(l);
Flash.current().success("继教号同步成功!");
}catch(Exception e){
e.printStackTrace();
Flash.current().success("继教号同步失败!");
}
return LIST_ACTION;
}
示例2: processRow
import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
private void processRow(ArrayList<String> headers, ArrayList<HSSFCell> data, ClientSession session, String className) {
HashMap<String, HSSFCell> fields = new HashMap<String, HSSFCell>();
for (int i = 0; i < data.size(); i++) {
HSSFCell existing = fields.get(headers.get(i));
String exVal = null;
if(existing != null) {
exVal = existing.toString();
}
// if there are more than one column with the same header, keep the value of the first if it is a "good" value, otherwise take the next value.
// --> similar to behavior of COALESCE
if(exVal == null || exVal.length() <= 0 || exVal.equals(" ") || exVal.startsWith("#ERR"))
fields.put(headers.get(i), data.get(i));
}
DomainObject instance = null;
Double objectID = getDoubleValueOfCell(fields.get("objectID"));
if (objectID != null) {
instance = server.getDomainObject(session, objectID.intValue(), ServerTools.getClassForName(className));
if (instance == null)
AtomTools.log(Level.WARNING, "Importer: cannot update DomainObject with ID " + objectID + ", since it does not exist. ", this);
else {
Boolean delete = getBooleanValueOfCell(fields.get("DELETE"));
if (delete != null && delete.booleanValue() == true) {
AtomTools.log(Level.INFO, "Importer: Deleting DomainObject " + objectID, this);
server.deleteDomainObject(session, instance);
} else {
AtomTools.log(Level.INFO, "Importer: Updating DomainObject " + objectID, this);
updateFields(instance, fields, className, session);
server.saveDomainObject(session, instance);
}
}
} else {
instance = createInstance(className);
AtomTools.log(Level.INFO, "Importer: Created new DomainObject with ID " + instance.getObjectID(), this);
updateFields(instance, fields, className, session);
server.saveDomainObject(session, instance);
}
}
示例3: readExcelFile
import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
public static ArrayList<Question> readExcelFile(Uri uri) {
questionArrayList.clear();
try{
// Creating Input Stream
File file = new File(uri.getPath());
FileInputStream myInput = new FileInputStream(file);
// Create a POIFSFileSystem object
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
// Create a workbook using the File System
HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);
// Get the first sheet from workbook
HSSFSheet mySheet = myWorkBook.getSheetAt(0);
/** We now need something to iterate through the cells.**/
Iterator rowIter = mySheet.rowIterator();
while(rowIter.hasNext()){
HSSFRow myRow = (HSSFRow) rowIter.next();
Iterator cellIter = myRow.cellIterator();
int i = 1;
while(cellIter.hasNext()){
HSSFCell myCell = (HSSFCell) cellIter.next();
if(i == 1) {
quesSt = myCell.toString();
i++;
}
else if(i == 2) {
op1 = myCell.toString();
i++;
}
else if(i == 3) {
op2 = myCell.toString();
i++;
}
else if(i == 4) {
op3 = myCell.toString();
i++;
}
else if(i == 5) {
op4 = myCell.toString();
i++;
}
else if(i == 6) {
ca = (int)Double.parseDouble(String.valueOf(myCell));
i++;
}
Log.d(TAG, "Cell Value: " + myCell.toString());
//Toast.makeText(context, "Cell Value: " + myCell.toString(), Toast.LENGTH_SHORT).show();
}
questionArrayList.add(new Question(quesSt,op1,op2,op3,op4,ca));
}
myInput.close();
}catch (Exception e){e.printStackTrace(); }
return questionArrayList;
}
示例4: readExcel2003
import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
public static ArrayList<ArrayList<ArrayList<Object>>> readExcel2003(File file){
try{
ArrayList<ArrayList<ArrayList<Object>>> sheetArray = new ArrayList<ArrayList<ArrayList<Object>>> ();
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(file));
for(int sheetNum = 0;sheetNum < wb.getNumberOfSheets();sheetNum++){
ArrayList<ArrayList<Object>> rowList = new ArrayList<ArrayList<Object>>();
ArrayList<Object> colList;
HSSFSheet sheet = wb.getSheetAt(sheetNum);
HSSFRow row;
HSSFCell cell;
Object value;
for(int i = 0 , rowCount = 0; rowCount < sheet.getPhysicalNumberOfRows() ; i++ ){
row = sheet.getRow(i);
colList = new ArrayList<Object>();
if(row == null){
//����ȡ��Ϊ��ʱ
if(i != sheet.getPhysicalNumberOfRows()){//�ж��Ƿ������һ��
rowList.add(colList);
}
continue;
}else{
rowCount++;
}
for( int j = 0 ; j <= row.getLastCellNum() ;j++){
cell = row.getCell(j);
if(cell == null ){
//���õ�Ԫ��Ϊ��
if(j != row.getLastCellNum()){//�ж��Ƿ��Ǹ��������һ����Ԫ��
colList.add("");
}
continue;
}
switch(cell.getCellType()){
case XSSFCell.CELL_TYPE_STRING:
value = cell.getStringCellValue();
break;
case XSSFCell.CELL_TYPE_NUMERIC:
if ("@".equals(cell.getCellStyle().getDataFormatString())) {
value = df.format(cell.getNumericCellValue());
} else if ("General".equals(cell.getCellStyle()
.getDataFormatString())) {
value = nf.format(cell.getNumericCellValue());
} else {
value = sdf.format(HSSFDateUtil.getJavaDate(cell
.getNumericCellValue()));
}
break;
case XSSFCell.CELL_TYPE_BOOLEAN:
value = Boolean.valueOf(cell.getBooleanCellValue());
break;
case XSSFCell.CELL_TYPE_BLANK:
value = "";
break;
default:
value = cell.toString();
}// end switch
colList.add(value);
}//end for j
rowList.add(colList);
}//end for i
sheetArray.add(rowList);
}// end sheetNum
return sheetArray;
}catch(Exception e){
return null;
}
}