You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by hitesh parmar <hi...@hotmail.com> on 2002/12/13 12:03:09 UTC

reading restricted cell values from excel

How do you read a cell value if the user has restricted values that can be 
entered in the cell?

I am currently writing a program that reads coordinates to specify data cell 
locations for excel using xml. I iterate through the xml extracting data 
from cells, until i reach a restricted value cell, please could someone help 
to get round this, would be much appreciated.

thanks.........hitesh example code...........

//iterate through list for element(s) from xml file
	    for (int i = 0; i < list.getLength(); i++)
    	    {



		     if (list.item(i).getNodeType() == Node.ELEMENT_NODE)
		     {
			TagName = list.item(i).getNodeName();
			System.out.println("TagName : " + TagName + " ");

			//for each element get attribute values
			Element el = (Element)list.item(i);

			//get attribute values for element to get data cell values from excel 
sheet
			tableValue = el.getAttribute("table");
			rowValue = el.getAttribute("row");
			int intRowValue = Integer.parseInt(rowValue);
			row = sheet.getRow(intRowValue);

			//System.out.println("row value " + intRowValue);
			cellValue = el.getAttribute("cell");
			intCellValue = Integer.parseInt(cellValue);
			cell = row.getCell((short)intCellValue);

			//System.out.println("cell value " + intCellValue);
			//nedd to check for cell dat type

			if(cell.getCellType() == HSSFCell.CELL_TYPE_STRING)
			{

			dataValue = cell.getStringCellValue();
			System.out.println("  This is string" + dataValue);
			}

			if(cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC)
			{

			Double tempDouble = new Double(cell.getNumericCellValue());
			dataValue = tempDouble.toString();
			System.out.print("  This is numeric " + dataValue);
			}


			//store values into row object
			Row r = new Row(TagName, dataValue, tableValue);
			dataMap.put(TagName + i, r);

		    }
	    }







_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail