(objeto [,]) range.get_Value (XL.XlRangeValueDataType.xlRangeValueDefault) provoca un error de conversión

Error

Cannot convert type 'string' to 'object[*,*]'

Ese es el error que he estado recibiendo. ¿Alguien puede darme algunos consejos para que pueda evitarlo? Gracias

Nota

Interesantemente,(object[,])range.get_Value(XL.XlRangeValueDataType.xlRangeValueDefault)

solo producirá este error cuandorange.Count == 1. Funciona bien cuando el recuento es igual o superior a 2.

Código de muestra

object[,] arrValue;  //global variable

private string[] createFormulaCollection()
        {
            ArrayList s = new ArrayList();
            try
            {
                //look at the currently active excel sheet
                //iterate through cells (not Null) and find the one contains IES(...)
                //save it into the arraylist
                //use dictionary to save position and value (position as key)
                workbook = Globals.ThisAddIn.Application.ActiveWorkbook;
                worksheet = Globals.ThisAddIn.Application.ActiveSheet;
                range = worksheet.UsedRange;

                MessageBox.Show(range.Count.ToString());


                if (range.Count > 1)
                {
                    //need to make sure there are at least 2 "ies" cells before converting to object[,]
                    arrValue = (object[,])range.get_Value(XL.XlRangeValueDataType.xlRangeValueDefault); 
                }
                else
                {
                    arrValue[1,1] = range.get_Value(XL.XlRangeValueDataType.xlRangeValueDefault); //my try here. seems still got problem though.
                }


            catch (Exception ex)
            {

            }
            return (string[])s.ToArray(typeof(string));
        }

Respuestas a la pregunta(2)

Su respuesta a la pregunta