M
mp
this is a method in a class to provide access to Excel
where _xlApp etc are private member vars for the respective objects
they shouldn't ever be null by the time this is called...but just in case...
public Range GetRange(string rangename)
{
Range rng=null ;
if (_xlApp != null)
{if (_xlWorkBook != null)
{if(_xlWorkSheet!=null)
{
rng = (Range)_xlWorkSheet.get_Range(rangename,
System.Reflection.Missing.Value);
_xlRange = rng;
}
}
}
return rng;
}
would it be advised to provide an else for each if
if (_xlApp != null)
{}
else
{throw exception or ???}
that would make the layered if clauses messy
or better to
if (_xlApp == null){...throw excep and bail}
if (_xlWorkBook == null){...throw excep and bail}
if (_xlWorkSheet == null){...throw excep and bail}
....aok so get the range...
thanks
mark
where _xlApp etc are private member vars for the respective objects
they shouldn't ever be null by the time this is called...but just in case...
public Range GetRange(string rangename)
{
Range rng=null ;
if (_xlApp != null)
{if (_xlWorkBook != null)
{if(_xlWorkSheet!=null)
{
rng = (Range)_xlWorkSheet.get_Range(rangename,
System.Reflection.Missing.Value);
_xlRange = rng;
}
}
}
return rng;
}
would it be advised to provide an else for each if
if (_xlApp != null)
{}
else
{throw exception or ???}
that would make the layered if clauses messy
or better to
if (_xlApp == null){...throw excep and bail}
if (_xlWorkBook == null){...throw excep and bail}
if (_xlWorkSheet == null){...throw excep and bail}
....aok so get the range...
thanks
mark