Esempio n. 1
0
 //public CT_Cell()
 //{
 //    this.extLstField = new CT_ExtensionList();
 //    //this.isField = new CT_Rst();
 //    //this.fField = new CT_CellFormula();
 //    this.sField = (uint)(0);
 //    this.tField = ST_CellType.n;
 //    this.cmField = ((uint)(0));
 //    this.vmField = ((uint)(0));
 //    this.phField = false;
 //}
 public void Set(CT_Cell cell)
 {
     fField = cell.fField;
     vField = cell.vField;
     isField = cell.isField;
     extLstField = cell.extLstField;
     rField = cell.rField;
     sField = cell.sField;
     tField = cell.tField;
     cmField = cell.cmField;
     vmField = cell.vmField;
     phField = cell.phField;
 }
Esempio n. 2
0
 public void unsetF()
 {
     this.fField = null;
 }
Esempio n. 3
0
        /// <summary>
        /// Set the cells type (numeric, formula or string)
        /// </summary>
        /// <param name="cellType"></param>
        public void SetCellType(CellType cellType)
        {
            CellType prevType = CellType;

            if (IsPartOfArrayFormulaGroup)
            {
                NotifyArrayFormulaChanging();
            }
            if (prevType == CellType.Formula && cellType != CellType.Formula)
            {
                ((XSSFWorkbook)Sheet.Workbook).OnDeleteFormula(this);
            }

            switch (cellType)
            {
                case CellType.Blank:
                    SetBlank();
                    break;
                case CellType.Boolean:
                    String newVal = ConvertCellValueToBoolean() ? TRUE_AS_STRING : FALSE_AS_STRING;
                    _cell.t= (ST_CellType.b);
                    _cell.v= (newVal);
                    break;
                case CellType.Numeric:
                    _cell.t = (ST_CellType.n);
                    break;
                case CellType.Error:
                    _cell.t = (ST_CellType.e);
                    break;
                case CellType.String:
                    if (prevType != CellType.String)
                    {
                        String str = ConvertCellValueToString();
                        XSSFRichTextString rt = new XSSFRichTextString(str);
                        rt.SetStylesTableReference(_stylesSource);
                        int sRef = _sharedStringSource.AddEntry(rt.GetCTRst());
                        _cell.v= sRef.ToString();
                    }
                    _cell.t= (ST_CellType.s);
                    break;
                case CellType.Formula:
                    if (!_cell.IsSetF())
                    {
                        CT_CellFormula f = new CT_CellFormula();
                        f.Value = "0";
                        _cell.f = (f);
                        if (_cell.IsSetT()) _cell.unsetT();
                    }
                    break;
                default:
                    throw new ArgumentException("Illegal cell type: " + cellType);
            }
            if (cellType != CellType.Formula && _cell.IsSetF())
            {
                _cell.unsetF();
            }
        }
Esempio n. 4
0
        private void SetFormula(String formula, FormulaType formulaType)
        {
            IWorkbook wb = _row.Sheet.Workbook;
            if (formula == null)
            {
                ((XSSFWorkbook)wb).OnDeleteFormula(this);
                if (_cell.IsSetF()) _cell.unsetF();
                return;
            }

            IFormulaParsingWorkbook fpb = XSSFEvaluationWorkbook.Create(wb);
            //validate through the FormulaParser
            FormulaParser.Parse(formula, fpb, formulaType, wb.GetSheetIndex(this.Sheet));

            CT_CellFormula f = new CT_CellFormula();
            f.Value = formula;
            _cell.f= (f);
            if (_cell.IsSetV()) _cell.unsetV();
        }
Esempio n. 5
0
 public CT_CellFormula Copy()
 {
     CT_CellFormula obj = new CT_CellFormula();
     obj.acaField = this.acaField;
     obj.bxField = this.bxField;
     obj.caField = this.caField;
     obj.del1Field = this.del1Field;
     obj.del2Field = this.del2Field;
     obj.dt2DField = this.dt2DField;
     obj.dtrField = this.dtrField;
     obj.r1Field = this.r1Field;
     obj.r2Field = this.r2Field;
     obj.refField = this.refField;
     obj.siField = this.siField;
     obj.siFieldSpecified = this.siFieldSpecified;
     obj.tField = this.tField;
     obj.valueField = this.valueField;
     return obj;
 }
Esempio n. 6
0
 public static CT_CellFormula Parse(XmlNode node, XmlNamespaceManager namespaceManager)
 {
     if (node == null)
         return null;
     CT_CellFormula ctObj = new CT_CellFormula();
     if (node.Attributes["t"] != null)
         ctObj.t = (ST_CellFormulaType)Enum.Parse(typeof(ST_CellFormulaType), node.Attributes["t"].Value);
     else
         ctObj.t = ST_CellFormulaType.normal;
     ctObj.aca = XmlHelper.ReadBool(node.Attributes["aca"]);
     ctObj.@ref = XmlHelper.ReadString(node.Attributes["ref"]);
     ctObj.dt2D = XmlHelper.ReadBool(node.Attributes["dt2D"]);
     ctObj.dtr = XmlHelper.ReadBool(node.Attributes["dtr"]);
     ctObj.del1 = XmlHelper.ReadBool(node.Attributes["del1"]);
     ctObj.del2 = XmlHelper.ReadBool(node.Attributes["del2"]);
     ctObj.r1 = XmlHelper.ReadString(node.Attributes["r1"]);
     ctObj.r2 = XmlHelper.ReadString(node.Attributes["r2"]);
     ctObj.ca = XmlHelper.ReadBool(node.Attributes["ca"]);
     ctObj.si = XmlHelper.ReadUInt(node.Attributes["si"]);
     ctObj.bx = XmlHelper.ReadBool(node.Attributes["bx"]);
     ctObj.Value = node.InnerText.Replace("\r","");
     return ctObj;
 }