2011年7月12日 星期二

two method to read the value of the cell in excel file

Pseudo code

Worksheet sheet;
Object[,] value1;
Object value2;


value1 = sheet.get_Range("A1", "D8").Value2; // Read a range.
value2 =   ((Range)sheet.Cells[1, 1]).Value2 ;  //Read the value of the cell.
value2 = sheet.get_Range("A1","A1").Value2;  //Read the value of the cell.
   
  if (((Range)sheet.Cells[1, 1]).Value2 != null) // Check the value before get it.
{
   value2 = ((Range)sheet.Cells[1, 1]).Value2.ToString();
}

沒有留言: