Beispiel #1
0
        /**
         * Standard equals method.  This compares the contents of two
         * format records, and not their indexCodes, which are ignored
         *
         * @param o the object to compare
         * @return TRUE if the two objects are equal, FALSE otherwise
         */
        public override bool Equals(object o)
        {
            if (o == this)
            {
                return(true);
            }

            if (!(o is FormatRecord))
            {
                return(false);
            }

            FormatRecord fr = (FormatRecord)o;

            // Initialized format comparison
            if (initialized && fr.initialized)
            {
                // Must be either a number or a date format
                if (date != fr.date ||
                    number != fr.number)
                {
                    return(false);
                }

                return(formatString.Equals(fr.formatString));
            }

            // Uninitialized format comparison
            return(formatString.Equals(fr.formatString));
        }
Beispiel #2
0
        /**
         * Copy constructor - can be invoked by public access
         *
         * @param fr the format to copy
         */
        public FormatRecord(FormatRecord fr)
            : base(Type.FORMAT)
        {
            initialized = false;

            formatString = fr.formatString;
            date         = fr.date;
            number       = fr.number;
            //    format = (java.text.Format) fr.format.clone();
        }
Beispiel #3
0
        /**
         * Sees if the extended formatting record at the specified position
         * represents a date.  First checks against the built in formats, and
         * then checks against the hash map of FormatRecords
         *
         * @param pos the xf format index
         * @return TRUE if this format index is formatted as a Date
         */
        public bool isDate(int pos)
        {
            XFRecord xfr = (XFRecord)xfRecords[pos];

            if (xfr.isDate())
            {
                return(true);
            }

            if (!formats.ContainsKey(xfr.getFormatRecord()))
            {
                return(false);
            }
            FormatRecord fmt = formats[xfr.getFormatRecord()] as FormatRecord;

            if (fmt == null)
            {
                return(false);
            }
            return(fmt.isDate());
        }
Beispiel #4
0
        /**
         * Gets the NumberFormat used to format the cell.
         *
         * @param pos the xf format index
         * @return the DateFormat object used to format the date in the original
         *     excel cell
         */
        public CSharpJExcel.Interop.NumberFormat getNumberFormat(int pos)
        {
            XFRecord xfr = (XFRecord)xfRecords[pos];

            if (xfr.isNumber())
            {
                return(xfr.getNumberFormat());
            }

            if (!formats.ContainsKey(xfr.getFormatRecord()))
            {
                return(null);
            }
            FormatRecord fr = formats[xfr.getFormatRecord()] as FormatRecord;

            if (fr == null)
            {
                return(null);
            }

            return(fr.isNumber() ? fr.getNumberFormat() : null);
        }