Example #1
0
        /**
         * Performs a deep copy of the specified cell, handling the cell format
         *
         * @param cell the cell to copy
         */
        private WritableCell deepCopyCell(Cell cell)
        {
            WritableCell c = shallowCopyCell(cell);

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

            if (c is ReadFormulaRecord)
            {
                ReadFormulaRecord rfr    = (ReadFormulaRecord)c;
                bool crossSheetReference = !rfr.handleImportedCellReferences
                                               (fromSheet.getWorkbook(),
                                               fromSheet.getWorkbook(),
                                               workbookSettings);

                if (crossSheetReference)
                {
                    try
                    {
                        //logger.warn("Formula " + rfr.getFormula() +
                        //            " in cell " +
                        //            CellReferenceHelper.getCellReference(cell.getColumn(),
                        //                                                 cell.getRow()) +
                        //            " cannot be imported because it references another " +
                        //            " sheet from the source workbook");
                    }
                    catch (FormulaException e)
                    {
                        //logger.warn("Formula  in cell " +
                        //            CellReferenceHelper.getCellReference(cell.getColumn(),
                        //                                                 cell.getRow()) +
                        //            " cannot be imported:  " + e.Message);
                    }

                    // Create a new error formula and add it instead
                    c = new Formula(cell.getColumn(), cell.getRow(), "\"ERROR\"");
                }
            }

            // Copy the cell format
            CellFormat cf    = c.getCellFormat();
            int        index = ((XFRecord)cf).getXFIndex();

            WritableCellFormat wcf = null;

            if (!xfRecords.ContainsKey(index))
            {
                wcf = copyCellFormat(cf);
            }
            else
            {
                wcf = xfRecords[index];
            }
            c.setCellFormat(wcf);

            return(c);
        }
Example #2
0
 /**
  * Copy constructor for formulas read in - invoked from writable formulas
  *
  * @param c the column
  * @param r the row
  * @param rfr the formula data to copy
  */
 public FormulaRecord(int c, int r, ReadFormulaRecord rfr)
     : base(Type.FORMULA, c, r, rfr)
 {
     try
     {
         copiedFrom   = rfr;
         formulaBytes = rfr.getFormulaBytes();
     }
     catch (FormulaException e)
     {
         // Fail silently
         //logger.error(string.Empty, e);
     }
 }