Esempio n. 1
0
        /// <summary>
        /// Returns a string representation of the cell
        /// This method returns a simple representation,
        /// anthing more complex should be in user code, with
        /// knowledge of the semantics of the sheet being Processed.
        /// Formula cells return the formula string,
        /// rather than the formula result.
        /// Dates are Displayed in dd-MMM-yyyy format
        /// Errors are Displayed as #ERR&lt;errIdx&gt;
        /// </summary>
        public override string ToString()
        {
            switch (CellType)
            {
            case CellType.Blank:
                return("");

            case CellType.Boolean:
                return(BooleanCellValue ? "TRUE" : "FALSE");

            case CellType.Error:
                return(Npoi.Core.SS.Formula.Eval.ErrorEval.GetText(((BoolErrRecord)_record).ErrorValue));

            case CellType.Formula:
                return(CellFormula);

            case CellType.Numeric:
                string        format    = CellStyle.GetDataFormatString();
                DataFormatter formatter = new DataFormatter();
                return(formatter.FormatCellValue(this));

            case CellType.String:
                return(StringCellValue);

            default:
                return("Unknown Cell Type: " + CellType);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Check if a cell Contains a date
        /// Since dates are stored internally in Excel as double values
        /// we infer it Is a date if it Is formatted as such.
        /// </summary>
        /// <param name="cell">The cell.</param>
        /// <returns>
        ///     <c>true</c> if [is cell date formatted] [the specified cell]; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsCellDateFormatted(Cell cell)
        {
            if (cell == null)
            {
                return(false);
            }
            bool bDate = false;

            double d = cell.NumericCellValue;

            if (DateUtil.IsValidExcelDate(d))
            {
                CellStyle style = cell.CellStyle;
                int       i     = style.DataFormat;
                String    f     = style.GetDataFormatString();
                bDate = IsADateFormat(i, f);
            }
            return(bDate);
        }
Esempio n. 3
0
 public JsValue GetDataFormat()
 {
     return(CellStyle.GetDataFormatString());
 }