示例#1
0
文件: CT_Dxfs.cs 项目: gechan/npoi
        public CT_Fill AddNewFill()
        {
            CT_Fill fill = new CT_Fill();

            this.fillField = fill;
            return(fill);
        }
示例#2
0
文件: Styles.cs 项目: zuiwanting/npoi
        public CT_Fill Copy()
        {
            CT_Fill obj = new CT_Fill();

            obj.patternFillField = this.patternFillField;
            return(obj);
        }
示例#3
0
 public CT_Fill Copy()
 {
     CT_Fill obj = new CT_Fill();
     obj.patternFillField = this.patternFillField;
     obj.gradientFillField = this.gradientFillField;
     return obj;
 }
示例#4
0
文件: CT_Border.cs 项目: zzy092/npoi
        public static CT_Border Parse(string p)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(p);
            return(Parse(doc.DocumentElement, CT_Fill.CreateDefaultNSM()));
        }
示例#5
0
 public void TestGetNotModifies()
 {
     CT_Fill ctFill = new CT_Fill();
     XSSFCellFill cellFill = new XSSFCellFill(ctFill);
     CT_PatternFill ctPatternFill = ctFill.AddNewPatternFill();
     ctPatternFill.patternType = (ST_PatternType.darkDown);
     Assert.AreEqual(ST_PatternType.darkDown, cellFill.GetPatternType());
 }
示例#6
0
 public void TestGetSetPatternType()
 {
     CT_Fill ctFill = new CT_Fill();
     XSSFCellFill cellFill = new XSSFCellFill(ctFill);
     CT_PatternFill ctPatternFill = ctFill.AddNewPatternFill();
     ctPatternFill.patternType = (ST_PatternType.solid);
     Assert.AreEqual(ST_PatternType.solid, cellFill.GetPatternType());
 }
示例#7
0
 public void TestGetFillForegroundColor()
 {
     CT_Fill ctFill = new CT_Fill();
     XSSFCellFill cellFill = new XSSFCellFill(ctFill);
     CT_PatternFill ctPatternFill = ctFill.AddNewPatternFill();
     CT_Color fgColor = ctPatternFill.AddNewFgColor();
     Assert.IsNotNull(cellFill.GetFillForegroundColor());
     fgColor.indexed = 8;
     fgColor.indexedSpecified = true;
     Assert.AreEqual(8, cellFill.GetFillForegroundColor().Indexed);
 }
示例#8
0
 public static CT_Fill Parse(XmlNode node, XmlNamespaceManager namespaceManager)
 {
     if (node == null)
         return null;
     CT_Fill ctObj = new CT_Fill();
     foreach (XmlNode childNode in node.ChildNodes)
     {
         if (childNode.LocalName == "patternFill")
             ctObj.patternFill = CT_PatternFill.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "gradientFill")
             ctObj.gradientFill = CT_GradientFill.Parse(childNode, namespaceManager);
     }
     return ctObj;
 }
示例#9
0
        public static CT_Fills Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Fills ctObj = new CT_Fills();

            ctObj.count = XmlHelper.ReadUInt(node.Attributes["count"]);
            ctObj.fill  = new List <CT_Fill>();
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "fill")
                {
                    ctObj.fill.Add(CT_Fill.Parse(childNode, namespaceManager));
                }
            }
            return(ctObj);
        }
示例#10
0
        public void SetUp()
        {
            stylesTable = new StylesTable();

            ctStylesheet = stylesTable.GetCTStylesheet();

            ctBorderA = new CT_Border();
            XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA);
            long borderId = stylesTable.PutBorder(borderA);
            Assert.AreEqual(1, borderId);

            XSSFCellBorder borderB = new XSSFCellBorder();
            Assert.AreEqual(1, stylesTable.PutBorder(borderB));

            ctFill = new CT_Fill();
            XSSFCellFill fill = new XSSFCellFill(ctFill);
            long fillId = stylesTable.PutFill(fill);
            Assert.AreEqual(2, fillId);

            ctFont = new CT_Font();
            XSSFFont font = new XSSFFont(ctFont);
            long fontId = stylesTable.PutFont(font);
            Assert.AreEqual(1, fontId);

            cellStyleXf = ctStylesheet.AddNewCellStyleXfs().AddNewXf();
            cellStyleXf.borderId = 1;
            cellStyleXf.fillId = 1;
            cellStyleXf.fontId = 1;

            cellXfs = ctStylesheet.AddNewCellXfs();
            cellXf = cellXfs.AddNewXf();
            cellXf.xfId = (1);
            cellXf.borderId = (1);
            cellXf.fillId = (1);
            cellXf.fontId = (1);
            stylesTable.PutCellStyleXf(cellStyleXf);
            stylesTable.PutCellXf(cellXf);
            cellStyle = new XSSFCellStyle(1, 1, stylesTable, null);

            Assert.IsNotNull(stylesTable.GetFillAt(1).GetCTFill().patternFill);
            Assert.AreEqual(ST_PatternType.darkGray, stylesTable.GetFillAt(1).GetCTFill().patternFill.patternType);
        }
示例#11
0
文件: CT_Dxfs.cs 项目: gechan/npoi
        public static CT_Dxf Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Dxf ctObj = new CT_Dxf();

            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "font")
                {
                    ctObj.font = CT_Font.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "numFmt")
                {
                    ctObj.numFmt = CT_NumFmt.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "fill")
                {
                    ctObj.fill = CT_Fill.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "alignment")
                {
                    ctObj.alignment = CT_CellAlignment.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "border")
                {
                    ctObj.border = CT_Border.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "protection")
                {
                    ctObj.protection = CT_CellProtection.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "extLst")
                {
                    ctObj.extLst = CT_ExtensionList.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }
示例#12
0
        public static CT_Fill Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Fill ctObj = new CT_Fill();

            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "patternFill")
                {
                    ctObj.patternFill = CT_PatternFill.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "gradientFill")
                {
                    ctObj.gradientFill = CT_GradientFill.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }
示例#13
0
        /**
         * Get a <b>copy</b> of the currently used CT_Fill, if none is used, return a new instance.
         */
        private CT_Fill GetCTFill()
        {
            CT_Fill ct;
            if (_cellXf.applyFill)
            {
                int FillIndex = (int)_cellXf.fillId;
                XSSFCellFill cf = _stylesSource.GetFillAt(FillIndex);

                ct = (CT_Fill)cf.GetCTFill().Copy();
            }
            else
            {
                ct = new CT_Fill();
            }
            return ct;
        }
示例#14
0
        public void TestGetFillPattern()
        {

            Assert.AreEqual(FillPattern.NoFill, cellStyle.FillPattern);

            int num = stylesTable.GetFills().Count;
            cellStyle.FillPattern = (FillPattern.SolidForeground);
            Assert.AreEqual(FillPattern.SolidForeground, cellStyle.FillPattern);
            Assert.AreEqual(num + 1, stylesTable.GetFills().Count);
            int FillId = (int)cellStyle.GetCoreXf().fillId;
            Assert.IsTrue(FillId > 0);
            //check Changes in the underlying xml bean
            CT_Fill ctFill = stylesTable.GetFillAt(FillId).GetCTFill();
            Assert.AreEqual(ST_PatternType.solid, ctFill.GetPatternFill().patternType);

            //setting the same fill multiple time does not update the styles table
            for (int i = 0; i < 3; i++)
            {
                cellStyle.FillPattern = (FillPattern.SolidForeground);
            }
            Assert.AreEqual(num + 1, stylesTable.GetFills().Count);

            cellStyle.FillPattern = (FillPattern.NoFill);
            Assert.AreEqual(FillPattern.NoFill, cellStyle.FillPattern);
            FillId = (int)cellStyle.GetCoreXf().fillId;
            ctFill = stylesTable.GetFillAt(FillId).GetCTFill();
            Assert.IsFalse(ctFill.GetPatternFill().IsSetPatternType());

        }
示例#15
0
        /**
         * Get a <b>copy</b> of the currently used CT_Fill, if none is used, return a new instance.
         */
        public CT_Fill GetCTFill()
        {
            CT_Fill ct;
            // bug 56295: handle missing applyFill attribute as "true" because Excel does as well
            if (!_cellXf.IsSetApplyFill() || _cellXf.applyFill)
            {
                int FillIndex = (int)_cellXf.fillId;
                XSSFCellFill cf = _stylesSource.GetFillAt(FillIndex);

                ct = (CT_Fill)cf.GetCTFill().Copy();
            }
            else
            {
                ct = new CT_Fill();
            }
            return ct;
        }
示例#16
0
        private void AddFill(CT_Fill fill)
        {
            int idx = _stylesSource.PutFill(new XSSFCellFill(fill));

            _cellXf.fillId = (uint)(idx);
            _cellXf.applyFill = (true);
        }
示例#17
0
 /**
  * Creates an empty CellFill
  */
 public XSSFCellFill()
 {
     _fill = new CT_Fill();
 }
示例#18
0
 /**
  * Creates a CellFill from the supplied parts
  *
  * @param fill - fill
  */
 public XSSFCellFill(CT_Fill fill)
 {
     _fill = fill;
 }
示例#19
0
文件: Styles.cs 项目: kenlen/npoi
 public CT_Fill AddNewFill()
 {
     CT_Fill fill = new CT_Fill();
     this.fillField = fill;
     return fill;
 }
示例#20
0
 private static CT_Fill[] CreateDefaultFills()
 {
     CT_Fill[] ctFill = new CT_Fill[] { new CT_Fill(), new CT_Fill() };
     ctFill[0].AddNewPatternFill().patternType = (ST_PatternType.none);
     ctFill[1].AddNewPatternFill().patternType = (ST_PatternType.darkGray);
     return ctFill;
 }
示例#21
0
 public XSSFPatternFormatting(CT_Fill fill)
 {
     _fill = fill;
 }