Ejemplo n.º 1
0
        /**
         * Gets the binary data for output to file
         *
         * @return the binary data
         */
        public override byte[] getData()
        {
            // Take the superclass cell data to take into account cell
            // rationalization
            byte[] celldata       = base.getData();
            byte[] expressiondata = null;

            try
            {
                if (parser == null)
                {
                    expressiondata = formula.getFormulaData();
                }
                else
                {
                    byte[] formulaBytes = parser.getBytes();
                    expressiondata = new byte[formulaBytes.Length + 16];
                    IntegerHelper.getTwoBytes(formulaBytes.Length, expressiondata, 14);
                    System.Array.Copy(formulaBytes, 0, expressiondata, 16,
                                      formulaBytes.Length);
                }

                // Set the recalculate on load bit
                expressiondata[8] |= 0x02;

                byte[] data = new byte[celldata.Length +
                                       expressiondata.Length];
                System.Array.Copy(celldata, 0, data, 0, celldata.Length);
                System.Array.Copy(expressiondata, 0, data,
                                  celldata.Length, expressiondata.Length);
                return(data);
            }
            catch (FormulaException e)
            {
                // Something has gone wrong trying to read the formula data eg. it
                // might be unsupported biff7 data
                //logger.warn(CellReferenceHelper.getCellReference(getColumn(), getRow()) + " " + e.Message);
                return(handleFormulaException());
            }
        }