Пример #1
0
        Object GetCellValue(String text, CellFormat format)
        {
            if (format == null)
            {
                return(text);
            }
            var formatId  = format.NumberFormatId;
            var strFormat = ExcelFormats.GetDateTimeFormat(formatId);

            if (!String.IsNullOrEmpty(strFormat))
            {
                if (Double.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out Double dblDate))
                {
                    return(DateTime.FromOADate(dblDate));
                }
            }
            else if (ExcelFormats.IsNumberFormat(formatId))
            {
                // hack
                if (Double.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out Double dblVal))
                {
                    return(dblVal);
                }
            }
            return(text);
        }
Пример #2
0
        Object GetCellValue(String text, CellFormat format)
        {
            if (format == null)
            {
                return(text);
            }
            var formatId  = format.NumberFormatId;
            var strFormat = ExcelFormats.GetDateTimeFormat(formatId);

            if (!String.IsNullOrEmpty(strFormat))
            {
                if (Double.TryParse(text, out Double dblDate))
                {
                    return(DateTime.FromOADate(dblDate));
                }
            }
            return(text);
        }