/// <summary> Gets the raw bytes for the formula. This will include the /// parsed tokens array. Used when copying spreadsheets /// /// </summary> /// <returns> the raw record data /// </returns> /// <exception cref=""> FormulaException /// </exception> public override sbyte[] getFormulaData() { // Get the tokens, taking into account the mapping from shared // formula specific values into normal values FormulaParser fp = new FormulaParser(getTokens(), this, ExternalSheet, NameTable, Sheet.Workbook.Settings); fp.parse(); sbyte[] rpnTokens = fp.Bytes; sbyte[] data = new sbyte[rpnTokens.Length + 22]; // Set the standard info for this cell IntegerHelper.getTwoBytes(Row, data, 0); IntegerHelper.getTwoBytes(Column, data, 2); IntegerHelper.getTwoBytes(XFIndex, data, 4); DoubleHelper.getIEEEBytes(Value, data, 6); // Now copy in the parsed tokens Array.Copy(rpnTokens, 0, data, 22, rpnTokens.Length); IntegerHelper.getTwoBytes(rpnTokens.Length, data, 20); // Lop off the standard information sbyte[] d = new sbyte[data.Length - 6]; Array.Copy(data, 6, d, 0, data.Length - 6); return(d); }
/** * Gets the raw bytes for the formula. This will include the * parsed tokens array. Used when copying spreadsheets * * @return the raw record data * @exception FormulaException */ public override byte[] getFormulaData() { if (!getSheet().getWorkbookBof().isBiff8()) { throw new FormulaException(FormulaException.BIFF8_SUPPORTED); } // Get the tokens, taking into account the mapping from shared // formula specific values into normal values FormulaParser fp = new FormulaParser (getTokens(), this, getExternalSheet(), getNameTable(), getSheet().getWorkbook().getSettings()); fp.parse(); byte[] rpnTokens = fp.getBytes(); byte[] data = new byte[rpnTokens.Length + 22]; // Set the standard info for this cell IntegerHelper.getTwoBytes(getRow(), data, 0); IntegerHelper.getTwoBytes(getColumn(), data, 2); IntegerHelper.getTwoBytes(getXFIndex(), data, 4); DoubleHelper.getIEEEBytes(value, data, 6); // Now copy in the parsed tokens System.Array.Copy(rpnTokens, 0, data, 22, rpnTokens.Length); IntegerHelper.getTwoBytes(rpnTokens.Length, data, 20); // Lop off the standard information byte[] d = new byte[data.Length - 6]; System.Array.Copy(data, 6, d, 0, data.Length - 6); return(d); }
/** * Gets the binary data for output to file * * @return the binary data */ public override byte[] getData() { byte[] data = new byte[8]; DoubleHelper.getIEEEBytes(margin, data, 0); return(data); }
/** * Gets the binary data for output to file * * @return the binary data */ public override byte[] getData() { byte[] celldata = base.getData(); byte[] data = new byte[celldata.Length + 8]; System.Array.Copy(celldata, 0, data, 0, celldata.Length); DoubleHelper.getIEEEBytes(value, data, celldata.Length); return(data); }
/** * Gets the token representation of this item in RPN * * @return the bytes applicable to this formula */ public override byte[] getBytes() { byte[] data = new byte[9]; data[0] = Token.DOUBLE.getCode(); DoubleHelper.getIEEEBytes(value, data, 1); return(data); }
/** * Gets the binary data for writing to the output file * * @return the binary data */ public override byte[] getData() { DoubleHelper.getIEEEBytes(iterationValue, data, 0); /* long val = Double.doubleToLongBits(iterationValue); * data[0] = (byte) (val & 0xff); * data[1] = (byte) ((val & 0xff00) >> 8); * data[2] = (byte) ((val & 0xff0000) >> 16); * data[3] = (byte) ((val & 0xff000000) >> 24); * data[4] = (byte) ((val & 0xff00000000L) >> 32); * data[5] = (byte) ((val & 0xff0000000000L) >> 40); * data[6] = (byte) ((val & 0xff000000000000L) >> 48); * data[7] = (byte) ((val & 0xff00000000000000L) >> 56) ; */ return(data); }
/** * Error formula specific exception handling. Can't really create * a formula (as it will look for a cell of that name, so just * create a STRING record containing the contents * * @return the bodged data */ public override byte[] handleFormulaException() { byte[] expressiondata = null; byte[] celldata = base.getCellData(); // Generate an appropriate dummy formula WritableWorkbookImpl w = getSheet().getWorkbook(); FormulaParser parser = new FormulaParser(getValue().ToString(), w, w, w.getSettings()); // Get the bytes for the dummy formula try { parser.parse(); } catch (FormulaException e2) { //logger.warn(e2.Message); } 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); // Store the value in the formula DoubleHelper.getIEEEBytes(getValue(), data, 6); return(data); }
/** * Gets the binary data for output to file * * @return the binary data */ public override byte[] getData() { data = new byte[34]; // Paper size IntegerHelper.getTwoBytes(paperSize, data, 0); // Scale factor IntegerHelper.getTwoBytes(scaleFactor, data, 2); // Page start IntegerHelper.getTwoBytes(pageStart, data, 4); // Fit width IntegerHelper.getTwoBytes(fitWidth, data, 6); // Fit height IntegerHelper.getTwoBytes(fitHeight, data, 8); // grbit int options = 0; if (order == PageOrder.RIGHT_THEN_DOWN) { options |= 0x01; } if (orientation == PageOrientation.PORTRAIT) { options |= 0x02; } if (pageStart != 0) { options |= 0x80; } if (!initialized) { options |= 0x04; } IntegerHelper.getTwoBytes(options, data, 10); // print resolution IntegerHelper.getTwoBytes(horizontalPrintResolution, data, 12); // vertical print resolution IntegerHelper.getTwoBytes(verticalPrintResolution, data, 14); // header margin DoubleHelper.getIEEEBytes(headerMargin, data, 16); // footer margin DoubleHelper.getIEEEBytes(footerMargin, data, 24); // Number of copies IntegerHelper.getTwoBytes(copies, data, 32); return(data); }