Ejemplo n.º 1
0
        public string GetXMLValueByRC(XmlNode RN, decimal rowno, decimal colno, NodeValType VType = NodeValType.innerXML, XMP_TempType TP = XMP_TempType.Model)
        {
            string namepath = String.Format("Sheet/cell[@row='{0}' and @col='{1}']", rowno, colno);

            if (TP == XMP_TempType.Formulas)
            {
                namepath = String.Format("Sheet/Formula/cell[@row='{0}' and @col='{1}']", rowno, colno);
            }
            //Console.WriteLine("GetXMLValueByRC: " + namepath);
            //Console.WriteLine("GetXMLValueByRC XML: " + RN.OwnerDocument.InnerXml);

            string rStr = "";

            try
            {
                switch (VType)
                {
                case NodeValType.innerXML:
                    rStr = RN.SelectSingleNode(namepath).InnerXml;
                    break;

                case NodeValType.Attributes:
                    rStr = RN.SelectSingleNode(namepath).Attributes["FormulaText"].Value;
                    break;

                default:
                    rStr = RN.SelectSingleNode(namepath).InnerText;
                    break;
                }
            }
            catch
            {
            }

            return(rStr);
        }
Ejemplo n.º 2
0
        public void UpdateXMLValueByRC(XmlNode RN, decimal rowno, decimal colno, string newvalue, NodeValType VType = NodeValType.innerXML, XMP_TempType TP = XMP_TempType.Model)
        {
            string namepath = String.Format("Sheet/cell[@row='{0}' and @col='{1}']", rowno, colno);

            if (TP == XMP_TempType.Formulas)
            {
                namepath = String.Format("Sheet/Formula/cell[@row='{0}' and @col='{1}']", rowno, colno);
            }
            //Console.WriteLine("UpdateXMLValueByRC:  "+namepath+"        "+newvalue);
            //Console.WriteLine("GetXMLValueByRC XML: " + RN.OwnerDocument.InnerXml);
            switch (VType)
            {
            case NodeValType.innerXML:
                RN.SelectSingleNode(namepath).InnerXml = newvalue;
                break;

            case NodeValType.Attributes:
                RN.SelectSingleNode(namepath).Attributes["FormulaText"].Value = newvalue;
                break;

            default:
                RN.SelectSingleNode(namepath).InnerText = newvalue;
                break;
            }
        }