private static string GetText(this CellType cell, IList <SharedStringItem> sharedStrings)
        {
            Contract.Requires(cell != null);

            var cellValue = cell.CellValue;

            var dataType = cell.DataType;

            if (cellValue != null)
            {
                var text = cellValue.Text ?? string.Empty;

                if ((dataType != null) && (dataType == CellValues.SharedString))
                {
                    if (sharedStrings != null)
                    {
                        int index;
                        if (int.TryParse(text, out index) && (index >= 0) && (index < sharedStrings.Count))
                        {
                            var stringItem = sharedStrings[index];
                            if (stringItem != null)
                            {
                                var descendants = stringItem.Descendants <OpenXmlLeafTextElement>();
                                if (descendants != null)
                                {
                                    var content = descendants.Select(element => element.Text);
                                    text = string.Concat(content);
                                }
                            }
                        }
                    }
                }

                return(text);
            }
            else
            {
                var descendants = cell.Descendants <OpenXmlLeafTextElement>();
                Contract.Assume(descendants != null);
                var content = descendants.Select(element => element.Text);
                var text    = string.Concat(content);
                return(text);
            }
        }