Example #1
0
 /**
  * Sets the format for the number based on the Excel spreadsheets' format.
  * This is called from SheetImpl when it has been definitely established
  * that this cell is a number and not a date
  *
  * @param f the format
  */
 public void setNumberFormat(CSharpJExcel.Interop.NumberFormat f)
 {
     if (f != null)
     {
         format = f;
     }
 }
        /**
         * Constructs this object from the raw data
         *
         * @param t the raw data
         * @param fr the available formats
         * @param si the sheet
         */
        public NumberRecord(Record t,FormattingRecords fr,SheetImpl si)
            : base(t,fr,si)
        {
            byte[] data = getRecord().getData();

            value = DoubleHelper.getIEEEDouble(data,6);

            // Now get the number format
            format = fr.getNumberFormat(getXFIndex());
            if (format == null)
                format = defaultFormat;
        }
Example #3
0
 /**
  * Quick and dirty function to return the contents of this cell as a string.
  * For more complex manipulation of the contents, it is necessary to cast
  * this interface to correct subinterface
  *
  * @return the contents of this cell as a string
  */
 public override string getContents()
 {
     if (format == null)
     {
         format = ((XFRecord)getCellFormat()).getNumberFormat();
         if (format == null)
         {
             format = defaultFormat;
         }
     }
     return(format.format(value));
 }
Example #4
0
 /**
  * Constructs this number
  *
  * @param r the zero based row
  * @param c the zero base column
  * @param val the value
  * @param xfi the xf index
  * @param fr the formatting records
  * @param si the sheet
  */
 public NumberValue(int r, int c, double val,
                    int xfi,
                    FormattingRecords fr,
                    SheetImpl si)
 {
     row               = r;
     column            = c;
     value             = val;
     format            = defaultFormat;
     xfIndex           = xfi;
     formattingRecords = fr;
     sheet             = si;
     initialized       = false;
 }
        /**
         * Constructs this object from the raw data
         *
         * @param t the raw data
         * @param fr the formatting record
         * @param es the external sheet
         * @param nt the name table
         * @param si the sheet
         */
        public NumberFormulaRecord(Record t, FormattingRecords fr,
                                   ExternalSheet es, WorkbookMethods nt,
                                   SheetImpl si)
            : base(t, fr, si)
        {
            externalSheet = es;
            nameTable     = nt;
            data          = getRecord().getData();

            format = fr.getNumberFormat(getXFIndex());

            if (format == null)
            {
                format = defaultFormat;
            }

            value = DoubleHelper.getIEEEDouble(data, 6);
        }
 /**
  * Constructs this number
  *
  * @param t the data
  * @param excelFile the excel biff data
  * @param v the value
  * @param fr the formatting records
  * @param es the external sheet
  * @param nt the name table
  * @param si the sheet
  */
 public SharedNumberFormulaRecord(Record t,
     File excelFile,
     double v,
     FormattingRecords fr,
     ExternalSheet es,
     WorkbookMethods nt,
     SheetImpl si)
     : base(t,fr,es,nt,si,excelFile.getPos())
 {
     value = v;
     format = defaultFormat;    // format is set up later from the
     // SharedFormulaRecord
 }
 /**
  * Sets the format for the number based on the Excel spreadsheets' format.
  * This is called from SheetImpl when it has been definitely established
  * that this cell is a number and not a date
  *
  * @param f the format
  */
 public void setNumberFormat(NumberFormat f)
 {
     if (f != null)
         {
         format = f;
         }
 }
        /**
         * Constructs this object from the raw data
         *
         * @param t the raw data
         * @param fr the formatting record
         * @param es the external sheet
         * @param nt the name table
         * @param si the sheet
         */
        public NumberFormulaRecord(Record t,FormattingRecords fr,
            ExternalSheet es,WorkbookMethods nt,
            SheetImpl si)
            : base(t,fr,si)
        {
            externalSheet = es;
            nameTable = nt;
            data = getRecord().getData();

            format = fr.getNumberFormat(getXFIndex());

            if (format == null)
                {
                format = defaultFormat;
                }

            value = DoubleHelper.getIEEEDouble(data,6);
        }
Example #9
0
        /**
         * Constructs this object from the raw data
         *
         * @param t the raw data
         * @param bt the biff type
         */
        public XFRecord(Record t,WorkbookSettings ws,BiffType bt)
            : base(t)
        {
            biffType = bt;

            byte[] data = getRecord().getData();

            fontIndex = IntegerHelper.getInt(data[0],data[1]);
            formatIndex = IntegerHelper.getInt(data[2],data[3]);
            date = false;
            number = false;

            // Compare against the date formats
            for (int i = 0; i < dateFormats.Length && date == false; i++)
                {
                if (formatIndex == dateFormats[i])
                    {
                    date = true;
                    dateFormat = javaDateFormats[i];
                    }
                }

            // Compare against the number formats
            for (int i = 0; i < numberFormats.Length && number == false; i++)
                {
                if (formatIndex == numberFormats[i])
                    {
                    number = true;
                    DecimalFormat df = new DecimalFormat((DecimalFormat)javaNumberFormats[i]);
            // TODO: CML - need to support DecimalFormatSymbols equivalent -- for now, we use the default from en-us
            //DecimalFormatSymbols symbols = new DecimalFormatSymbols(ws.getLocale());
            //df.setDecimalFormatSymbols(symbols);
                    numberFormat = df;
                    //numberFormat = javaNumberFormats[i];
                    }
                }

            // Initialize the parent format and the type
            int cellAttributes = IntegerHelper.getInt(data[4],data[5]);
            parentFormat = (cellAttributes & 0xfff0) >> 4;

            int formatType = cellAttributes & 0x4;
            xfFormatType = formatType == 0 ? cell : style;
            locked = ((cellAttributes & 0x1) != 0);
            hidden = ((cellAttributes & 0x2) != 0);

            if (xfFormatType == cell &&
                (parentFormat & 0xfff) == 0xfff)
                {
                // Something is screwy with the parent format - set to zero
                parentFormat = 0;
                //logger.warn("Invalid parent format found - ignoring");
                }

            initialized = false;
            read = true;
            formatInfoInitialized = false;
            copied = false;
        }