Exemplo n.º 1
0
        protected bool IsTextEmpty(HSSFCell cell)
        {
            string value;

            switch (cell.CellType)
            {
            case CellType.STRING:
                // XXX: enrich
                value = cell.RichStringCellValue.String;
                break;

            case CellType.FORMULA:
                switch (cell.CachedFormulaResultType)
                {
                case CellType.STRING:
                    HSSFRichTextString str = cell.RichStringCellValue as HSSFRichTextString;
                    if (str == null || str.Length <= 0)
                    {
                        return(false);
                    }

                    value = str.ToString();
                    break;

                case CellType.NUMERIC:
                    HSSFCellStyle style = cell.CellStyle as HSSFCellStyle;
                    if (style == null)
                    {
                        return(false);
                    }

                    value = (_formatter.FormatRawCellContents(cell.NumericCellValue, style.DataFormat, style.GetDataFormatString()));
                    break;

                case CellType.BOOLEAN:
                    value = cell.BooleanCellValue.ToString();
                    break;

                case CellType.ERROR:
                    value = ErrorEval.GetText(cell.ErrorCellValue);
                    break;

                default:
                    value = string.Empty;
                    break;
                }
                break;

            case CellType.BLANK:
                value = string.Empty;
                break;

            case CellType.NUMERIC:
                value = _formatter.FormatCellValue(cell);
                break;

            case CellType.BOOLEAN:
                value = cell.BooleanCellValue.ToString();
                break;

            case CellType.ERROR:
                value = ErrorEval.GetText(cell.ErrorCellValue);
                break;

            default:
                return(true);
            }

            return(string.IsNullOrEmpty(value));
        }