示例#1
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);
        }
示例#2
0
 public CT_Shape3D()
 {
     this.extLstField       = new CT_OfficeArtExtensionList();
     this.contourClrField   = new CT_Color();
     this.extrusionClrField = new CT_Color();
     this.bevelBField       = new CT_Bevel();
     this.bevelTField       = new CT_Bevel();
     this.zField            = ((long)(0));
     this.extrusionHField   = ((long)(0));
     this.contourWField     = ((long)(0));
     this.prstMaterialField = ST_PresetMaterialType.warmMatte;
 }
示例#3
0
        /**
         * Get the background fill color.
         *
         * @return fill color, null if color is not set
         */
        public XSSFColor GetFillBackgroundColor()
        {
            CT_PatternFill ptrn = _fill.GetPatternFill();

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

            CT_Color CT_Color = ptrn.bgColor;

            return(CT_Color == null ? null : new XSSFColor(CT_Color));
        }
示例#4
0
        /**
         * Get the foreground fill color.
         *
         * @return XSSFColor - foreground color. null if color is not set
         */
        public XSSFColor GetFillForegroundColor()
        {
            CT_PatternFill ptrn = _fill.GetPatternFill();

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

            CT_Color ctColor = ptrn.fgColor;

            return(ctColor == null ? null : new XSSFColor(ctColor));
        }
示例#5
0
        public void setBottomBorderColor(CT_Color color)
        {
            CT_BorderPr pr = _border.IsSetBottom() ? _border.bottom : _border.AddNewBottom();

            if (color == null)
            {
                pr.UnsetColor();
            }
            else
            {
                pr.color = (color);
            }
        }
示例#6
0
        public void setDiagonalBorderColor(CT_Color color)
        {
            CT_BorderPr pr = _border.IsSetDiagonal() ? _border.diagonal : _border.AddNewDiagonal();

            if (color == null)
            {
                pr.UnsetColor();
            }
            else
            {
                pr.color = (color);
            }
        }
示例#7
0
        public void setRightBorderColor(CT_Color color)
        {
            CT_BorderPr pr = _border.IsSetRight() ? _border.right : _border.AddNewRight();

            if (color == null)
            {
                pr.UnsetColor();
            }
            else
            {
                pr.color = (color);
            }
        }
示例#8
0
        private void SetFillForegroundColor(CT_Color color)
        {
            CT_PatternFill ptrn = _fill.IsSetPatternFill() ? _fill.GetPatternFill() : _fill.AddNewPatternFill();

            if (color == null)
            {
                ptrn.UnsetFgColor();
            }
            else
            {
                ptrn.fgColor = (color);
            }
        }
示例#9
0
        private void SetFillBackgroundColor(CT_Color color)
        {
            CT_PatternFill ptrn = _fill.IsSetPatternFill() ? _fill.patternFill : _fill.AddNewPatternFill();

            if (color == null)
            {
                ptrn.UnsetBgColor();
            }
            else
            {
                ptrn.bgColor = (color);
            }
        }
示例#10
0
        public void setTopBorderColor(CT_Color color)
        {
            CT_BorderPr pr = _border.IsSetTop() ? _border.top : _border.AddNewTop();

            if (color == null)
            {
                pr.UnsetColor();
            }
            else
            {
                pr.color = (color);
            }
        }
 public XMLColorModel(CT_Color color, XMLPaletteModel palette)
 {
     this._palette = palette;
     if (color == null)
     {
         this._color          = new CT_Color();
         this._color.Rgb_Attr = "FF000000";
     }
     else
     {
         this._color = color;
     }
 }
示例#12
0
        public void TestColor()
        {
            CT_Font  ctFont = new CT_Font();
            CT_Color color  = ctFont.AddNewColor();

            color.indexed = (uint)(XSSFFont.DEFAULT_FONT_COLOR);
            ctFont.SetColorArray(0, color);

            XSSFFont xssfFont = new XSSFFont(ctFont);

            Assert.AreEqual(IndexedColors.Black.Index, xssfFont.Color);

            xssfFont.Color = IndexedColors.Red.Index;
            Assert.AreEqual((uint)IndexedColors.Red.Index, ctFont.GetColorArray(0).indexed);
        }
示例#13
0
        public void TestThemeColor()
        {
            CT_Font  ctFont = new CT_Font();
            CT_Color color  = ctFont.AddNewColor();

            color.theme          = (1);
            color.themeSpecified = true;
            ctFont.SetColorArray(0, color);

            XSSFFont xssfFont = new XSSFFont(ctFont);

            Assert.AreEqual((short)ctFont.GetColorArray(0).theme, xssfFont.GetThemeColor());

            xssfFont.SetThemeColor(IndexedColors.Red.Index);
            Assert.AreEqual((uint)IndexedColors.Red.Index, ctFont.GetColorArray(0).theme);
        }
示例#14
0
        public XSSFColor GetXSSFColor()
        {
            CT_Color color1 = this._ctFont.sizeOfColorArray() == 0 ? (CT_Color)null : this._ctFont.GetColorArray(0);

            if (color1 == null)
            {
                return((XSSFColor)null);
            }
            XSSFColor color2 = new XSSFColor(color1);

            if (this._themes != null)
            {
                this._themes.InheritFromThemeAsRequired(color2);
            }
            return(color2);
        }
示例#15
0
        public XSSFColor GetFillForegroundColor()
        {
            CT_PatternFill patternFill = this._fill.GetPatternFill();

            if (patternFill == null)
            {
                return((XSSFColor)null);
            }
            CT_Color fgColor = patternFill.fgColor;

            if (fgColor != null)
            {
                return(new XSSFColor(fgColor));
            }
            return((XSSFColor)null);
        }
示例#16
0
        public XSSFColor GetFillBackgroundColor()
        {
            CT_PatternFill patternFill = this._fill.GetPatternFill();

            if (patternFill == null)
            {
                return((XSSFColor)null);
            }
            CT_Color bgColor = patternFill.bgColor;

            if (bgColor != null)
            {
                return(new XSSFColor(bgColor));
            }
            return((XSSFColor)null);
        }
示例#17
0
 public CT_ColorScheme()
 {
     this.extLstField   = new CT_OfficeArtExtensionList();
     this.folHlinkField = new CT_Color();
     this.hlinkField    = new CT_Color();
     this.accent6Field  = new CT_Color();
     this.accent5Field  = new CT_Color();
     this.accent4Field  = new CT_Color();
     this.accent3Field  = new CT_Color();
     this.accent2Field  = new CT_Color();
     this.accent1Field  = new CT_Color();
     this.lt2Field      = new CT_Color();
     this.dk2Field      = new CT_Color();
     this.lt1Field      = new CT_Color();
     this.dk1Field      = new CT_Color();
 }
示例#18
0
 public CT_ColorScheme()
 {
     this.extLstField = new CT_OfficeArtExtensionList();
     this.folHlinkField = new CT_Color();
     this.hlinkField = new CT_Color();
     this.accent6Field = new CT_Color();
     this.accent5Field = new CT_Color();
     this.accent4Field = new CT_Color();
     this.accent3Field = new CT_Color();
     this.accent2Field = new CT_Color();
     this.accent1Field = new CT_Color();
     this.lt2Field = new CT_Color();
     this.dk2Field = new CT_Color();
     this.lt1Field = new CT_Color();
     this.dk1Field = new CT_Color();
 }
        public XMLColorModel Clone()
        {
            CT_Color cT_Color = new CT_Color();

            if (this._color.Rgb_Attr != null)
            {
                cT_Color.Rgb_Attr = this._color.Rgb_Attr;
            }
            if (this._color.Indexed_Attr_Is_Specified)
            {
                cT_Color.Indexed_Attr = this._color.Indexed_Attr;
            }
            if (this._color.Theme_Attr_Is_Specified)
            {
                cT_Color.Theme_Attr = this._color.Theme_Attr;
            }
            cT_Color.Tint_Attr = this._color.Tint_Attr;
            cT_Color.Auto_Attr = this._color.Auto_Attr;
            return(new XMLColorModel(cT_Color, this._palette));
        }
示例#20
0
 public CT_TextParagraphProperties()
 {
     this.extLstField    = new CT_OfficeArtExtensionList();
     this.defRPrField    = new CT_TextCharacterProperties();
     this.tabLstField    = new List <CT_TextTabStop>();
     this.buBlipField    = new CT_TextBlipBullet();
     this.buCharField    = new CT_TextCharBullet();
     this.buAutoNumField = new CT_TextAutonumberBullet();
     this.buNoneField    = new CT_TextNoBullet();
     this.buFontField    = new CT_TextFont();
     this.buFontTxField  = new CT_TextBulletTypefaceFollowText();
     this.buSzPtsField   = new CT_TextBulletSizePoint();
     this.buSzPctField   = new CT_TextBulletSizePercent();
     this.buSzTxField    = new CT_TextBulletSizeFollowText();
     this.buClrField     = new CT_Color();
     this.buClrTxField   = new CT_TextBulletColorFollowText();
     this.spcAftField    = new CT_TextSpacing();
     this.spcBefField    = new CT_TextSpacing();
     this.lnSpcField     = new CT_TextSpacing();
 }
示例#21
0
        public static CT_Shape3D Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Shape3D ctObj = new CT_Shape3D();

            ctObj.z          = XmlHelper.ReadLong(node.Attributes["z"]);
            ctObj.extrusionH = XmlHelper.ReadLong(node.Attributes["extrusionH"]);
            ctObj.contourW   = XmlHelper.ReadLong(node.Attributes["contourW"]);
            if (node.Attributes["prstMaterial"] != null)
            {
                ctObj.prstMaterial = (ST_PresetMaterialType)Enum.Parse(typeof(ST_PresetMaterialType), node.Attributes["prstMaterial"].Value);
            }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "bevelT")
                {
                    ctObj.bevelT = CT_Bevel.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "bevelB")
                {
                    ctObj.bevelB = CT_Bevel.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "extrusionClr")
                {
                    ctObj.extrusionClr = CT_Color.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "contourClr")
                {
                    ctObj.contourClr = CT_Color.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "extLst")
                {
                    ctObj.extLst = CT_OfficeArtExtensionList.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }
示例#22
0
        public void TestRgbColor()
        {
            CT_Font  ctFont = new CT_Font();
            CT_Color color  = ctFont.AddNewColor();

            //Integer.toHexString(0xFFFFFF).getBytes() = [102, 102, 102, 102, 102, 102]
            color.SetRgb(Encoding.ASCII.GetBytes("ffffff"));
            ctFont.SetColorArray(0, color);

            XSSFFont xssfFont = new XSSFFont(ctFont);

            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[0], xssfFont.GetXSSFColor().GetRgb()[0]);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[1], xssfFont.GetXSSFColor().GetRgb()[1]);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[2], xssfFont.GetXSSFColor().GetRgb()[2]);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[3], xssfFont.GetXSSFColor().GetRgb()[3]);

            //Integer.toHexString(0xF1F1F1).getBytes() = [102, 49, 102, 49, 102, 49]
            color.SetRgb(Encoding.ASCII.GetBytes("f1f1f1"));
            XSSFColor newColor = new XSSFColor(color);

            xssfFont.SetColor(newColor);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[2], newColor.GetRgb()[2]);
        }
示例#23
0
        /**
         * Copy font attributes from CTFont bean into CTRPrElt bean
         */
        private void SetRunAttributes(CT_Font ctFont, CT_RPrElt pr)
        {
            if (ctFont.SizeOfBArray() > 0)
            {
                pr.AddNewB().val = (ctFont.GetBArray(0).val);
            }
            if (ctFont.sizeOfUArray() > 0)
            {
                pr.AddNewU().val = (ctFont.GetUArray(0).val);
            }
            if (ctFont.sizeOfIArray() > 0)
            {
                pr.AddNewI().val = (ctFont.GetIArray(0).val);
            }
            if (ctFont.sizeOfColorArray() > 0)
            {
                CT_Color c1 = ctFont.GetColorArray(0);
                CT_Color c2 = pr.AddNewColor();
                if (c1.IsSetAuto())
                {
                    c2.auto          = (c1.auto);
                    c2.autoSpecified = true;
                }
                if (c1.IsSetIndexed())
                {
                    c2.indexed          = (c1.indexed);
                    c2.indexedSpecified = true;
                }
                if (c1.IsSetRgb())
                {
                    c2.SetRgb(c1.rgb);
                    c2.rgbSpecified = true;
                }
                if (c1.IsSetTheme())
                {
                    c2.theme          = (c1.theme);
                    c2.themeSpecified = true;
                }
                if (c1.IsSetTint())
                {
                    c2.tint          = (c1.tint);
                    c2.tintSpecified = true;
                }
            }

            if (ctFont.sizeOfSzArray() > 0)
            {
                pr.AddNewSz().val = (ctFont.GetSzArray(0).val);
            }
            if (ctFont.sizeOfNameArray() > 0)
            {
                pr.AddNewRFont().val = (ctFont.name.val);
            }
            if (ctFont.sizeOfFamilyArray() > 0)
            {
                pr.AddNewFamily().val = (ctFont.GetFamilyArray(0).val);
            }
            if (ctFont.sizeOfSchemeArray() > 0)
            {
                pr.AddNewScheme().val = (ctFont.GetSchemeArray(0).val);
            }
            if (ctFont.sizeOfCharsetArray() > 0)
            {
                pr.AddNewCharset().val = (ctFont.GetCharsetArray(0).val);
            }
            if (ctFont.sizeOfCondenseArray() > 0)
            {
                pr.AddNewCondense().val = (ctFont.GetCondenseArray(0).val);
            }
            if (ctFont.sizeOfExtendArray() > 0)
            {
                pr.AddNewExtend().val = (ctFont.GetExtendArray(0).val);
            }
            if (ctFont.sizeOfVertAlignArray() > 0)
            {
                pr.AddNewVertAlign().val = (ctFont.GetVertAlignArray(0).val);
            }
            if (ctFont.sizeOfOutlineArray() > 0)
            {
                pr.AddNewOutline().val = (ctFont.GetOutlineArray(0).val);
            }
            if (ctFont.sizeOfShadowArray() > 0)
            {
                pr.AddNewShadow().val = (ctFont.GetShadowArray(0).val);
            }
            if (ctFont.sizeOfStrikeArray() > 0)
            {
                pr.AddNewStrike().val = (ctFont.GetStrikeArray(0).val);
            }
        }
示例#24
0
 /**
  * Create an instance of XSSFColor from the supplied XML bean
  */
 public XSSFColor(CT_Color color)
 {
     this.ctColor = color;
 }
示例#25
0
 /**
  * Create an new instance of XSSFColor
  */
 public XSSFColor()
 {
     this.ctColor = new CT_Color();
 }
示例#26
0
文件: Sheet.cs 项目: qljiong/npoi
 public CT_ChartsheetPr()
 {
     this.tabColorField = new CT_Color();
     this.publishedField = true;
 }
示例#27
0
 public XMLColorModel GetColorFromCT(CT_Color color)
 {
     return(new XMLColorModel(color, this));
 }
 public XMLColorModel(string argb)
 {
     this._color          = new CT_Color();
     this._color.Rgb_Attr = argb;
 }
示例#29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sheet"></param>
        /// <param name="startAddress"></param>
        /// <param name="dataTable"></param>
        /// <param name="iWorkbook"></param>
        public void FillDataFromTable(XSSFWorkbook iWorkbook, XSSFSheet sheet, string startAddress, DataTable dataTable)
        {
            XSSFCellStyle headerCellStyle = (XSSFCellStyle)iWorkbook.CreateCellStyle();
            CT_Color      ctColor         = new CT_Color();

            ctColor.SetRgb(112, 173, 71);
            XSSFColor xssfColor = new XSSFColor(ctColor);

            headerCellStyle.SetFillBackgroundColor(xssfColor);
            headerCellStyle.SetFillForegroundColor(xssfColor);

            XSSFFont hssfFont = iWorkbook.CreateFont() as XSSFFont;

            hssfFont.FontHeightInPoints = 10;
            hssfFont.FontName           = "宋体";
            hssfFont.Boldweight         = 700;
            headerCellStyle.SetFont(hssfFont);

            XSSFCellStyle contentCellStyle = (XSSFCellStyle)iWorkbook.CreateCellStyle();
            XSSFFont      contentHssfFont  = iWorkbook.CreateFont() as XSSFFont;

            contentHssfFont.FontHeightInPoints = 10;
            contentHssfFont.FontName           = "宋体";
            contentCellStyle.SetFont(contentHssfFont);

            string rowIndexStr  = string.Empty;
            string cellIndexStr = string.Empty;
            int    cellIndex    = 0;

            for (int i = 0; i < startAddress.Length; i++)
            {
                int tempNum;
                if (int.TryParse(startAddress[i].ToString(), out tempNum))
                {
                    rowIndexStr += "" + tempNum;
                }
                else
                {
                    cellIndexStr += "" + startAddress[i];
                }
            }
            var rowIndex = Convert.ToInt32(rowIndexStr);

            for (int i = cellIndexStr.Length - 1; i >= 0; i--)
            {
                if (i == cellIndexStr.Length - 1)
                {
                    cellIndex += cellIndexStr[i] - 65;
                }
                else
                {
                    cellIndex += (cellIndexStr[i] - 64) * 26;
                }
            }

            cellIndex = 0;

            //textBox1.Text += "\r\n 共有数据:" + _DataTable.Rows.Count;

            int tempCellIndex = cellIndex;

            try
            {
                //sheet分开包含表头
                if (!ckbSheet.Checked)
                {
                    rowIndex = sheet.LastRowNum;
                    if (rowIndex != 0)
                    {
                        rowIndex++;
                    }
                }

                //是否包含表头
                XSSFRow  excelRow;
                XSSFCell excelCell;
                if (ckbIsIncludeHeader.Checked && rowIndex <= 1)
                {
                    excelRow = sheet.GetRow(rowIndex) as XSSFRow ?? sheet.CreateRow(rowIndex) as XSSFRow;
                    excelRow.HeightInPoints = 20;
                    foreach (DataColumn dataColumn in dataTable.Columns)
                    {
                        excelCell = excelRow.GetCell(tempCellIndex) as XSSFCell;
                        if (excelCell == null)
                        {
                            excelCell = excelRow.CreateCell(tempCellIndex) as XSSFCell;
                        }
                        if (string.IsNullOrEmpty(dataColumn.ColumnName))
                        {
                            excelCell.SetCellType(CellType.Blank);
                            excelCell.CellStyle = headerCellStyle;
                            tempCellIndex++;
                        }
                        else
                        {
                            excelCell.SetCellType(CellType.String);
                            excelCell.SetCellValue(Convert.ToString(dataColumn.ColumnName));
                            excelCell.CellStyle = headerCellStyle;
                            tempCellIndex++;
                        }
                    }
                    rowIndex++;
                    tempCellIndex = cellIndex;
                }


                //填充数据
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    excelRow = sheet.GetRow(rowIndex) as XSSFRow ?? sheet.CreateRow(rowIndex) as XSSFRow;
                    excelRow.HeightInPoints = 20;
                    foreach (DataColumn dataColumn in dataTable.Columns)
                    {
                        excelCell = excelRow.GetCell(tempCellIndex) as XSSFCell;
                        if (excelCell == null)
                        {
                            excelCell = excelRow.CreateCell(tempCellIndex) as XSSFCell;
                        }

                        if (dataRow[dataColumn] == DBNull.Value || string.IsNullOrEmpty(Convert.ToString(dataRow[dataColumn])))
                        {
                            excelCell.SetCellType(CellType.Blank);
                            excelCell.CellStyle = contentCellStyle;
                            tempCellIndex++;
                            continue;
                        }
                        if (dataRow[dataColumn] is decimal || dataRow[dataColumn] is int)
                        {
                            excelCell.SetCellType(CellType.Numeric);
                            excelCell.SetCellValue(Convert.ToDouble(dataRow[dataColumn]));
                            excelCell.CellStyle = contentCellStyle;
                        }
                        else
                        {
                            excelCell.SetCellType(CellType.String);
                            excelCell.SetCellValue(Convert.ToString(dataRow[dataColumn]));
                            excelCell.CellStyle = contentCellStyle;
                        }

                        tempCellIndex++;
                    }
                    tempCellIndex = cellIndex;
                    rowIndex++;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("行" + rowIndex + "列" + tempCellIndex + "_" + ex.Message, ex);
            }
        }
示例#30
0
        public void TestThemesTableColors()
        {
            // Load our two test workbooks
            XSSFWorkbook simple  = XSSFTestDataSamples.OpenSampleWorkbook(testFileSimple);
            XSSFWorkbook complex = XSSFTestDataSamples.OpenSampleWorkbook(testFileComplex);
            // Save and re-load them, to check for stability across that
            XSSFWorkbook simpleRS  = XSSFTestDataSamples.WriteOutAndReadBack(simple) as XSSFWorkbook;
            XSSFWorkbook complexRS = XSSFTestDataSamples.WriteOutAndReadBack(complex) as XSSFWorkbook;

            // Fetch fresh copies to test with
            simple  = XSSFTestDataSamples.OpenSampleWorkbook(testFileSimple);
            complex = XSSFTestDataSamples.OpenSampleWorkbook(testFileComplex);
            // Files and descriptions
            Dictionary <String, XSSFWorkbook> workbooks = new Dictionary <String, XSSFWorkbook>();

            workbooks.Add(testFileSimple, simple);
            workbooks.Add("Re-Saved_" + testFileSimple, simpleRS);
            workbooks.Add(testFileComplex, complex);
            workbooks.Add("Re-Saved_" + testFileComplex, complexRS);

            // Sanity check
            //Assert.AreEqual(rgbExpected.Length, rgbExpected.Length);

            // For offline testing
            bool createFiles = false;

            // Check each workbook in turn, and verify that the colours
            //  for the theme-applied cells in Column A are correct
            foreach (String whatWorkbook in workbooks.Keys)
            {
                XSSFWorkbook workbook = workbooks[whatWorkbook];
                XSSFSheet    sheet    = workbook.GetSheetAt(0) as XSSFSheet;
                int          startRN  = 0;
                if (whatWorkbook.EndsWith(testFileComplex))
                {
                    startRN++;
                }

                for (int rn = startRN; rn < rgbExpected.Length + startRN; rn++)
                {
                    XSSFRow row = sheet.GetRow(rn) as XSSFRow;
                    Assert.IsNotNull(row, "Missing row " + rn + " in " + whatWorkbook);
                    String   ref1 = (new CellReference(rn, 0)).FormatAsString();
                    XSSFCell cell = row.GetCell(0) as XSSFCell;
                    Assert.IsNotNull(cell,
                                     "Missing cell " + ref1 + " in " + whatWorkbook);

                    int          expectedThemeIdx = rn - startRN;
                    ThemeElement themeElem        = ThemeElement.ById(expectedThemeIdx);
                    Assert.AreEqual(themeElem.name.ToLower(), cell.StringCellValue,
                                    "Wrong theme at " + ref1 + " in " + whatWorkbook);

                    // Fonts are theme-based in their colours
                    XSSFFont font    = (cell.CellStyle as XSSFCellStyle).GetFont();
                    CT_Color ctColor = font.GetCTFont().GetColorArray(0);
                    Assert.IsNotNull(ctColor);
                    Assert.AreEqual(true, ctColor.IsSetTheme());
                    Assert.AreEqual(themeElem.idx, ctColor.theme);

                    // Get the colour, via the theme
                    XSSFColor color = font.GetXSSFColor();

                    // Theme colours aren't tinted
                    Assert.AreEqual(color.HasTint, false);
                    // Check the RGB part (no tint)
                    Assert.AreEqual(rgbExpected[expectedThemeIdx], HexDump.EncodeHexString(color.RGB),
                                    "Wrong theme colour " + themeElem.name + " on " + whatWorkbook);

                    long themeIdx = font.GetCTFont().GetColorArray(0).theme;
                    Assert.AreEqual(expectedThemeIdx, themeIdx,
                                    "Wrong theme index " + expectedThemeIdx + " on " + whatWorkbook
                                    );

                    if (createFiles)
                    {
                        XSSFCellStyle cs = row.Sheet.Workbook.CreateCellStyle() as XSSFCellStyle;
                        cs.SetFillForegroundColor(color);
                        cs.FillPattern = FillPatternType.SolidForeground;
                        row.CreateCell(1).CellStyle = (cs);
                    }
                }

                if (createFiles)
                {
                    FileStream fos = new FileStream("Generated_" + whatWorkbook, FileMode.Create, FileAccess.ReadWrite);
                    workbook.Write(fos);
                    fos.Close();
                }
            }
        }
示例#31
0
        /**
         *
         * CTRPrElt --> CTFont adapter
         */
        protected static CT_Font ToCTFont(CT_RPrElt pr)
        {
            CT_Font ctFont = new CT_Font();

            if (pr.SizeOfBArray() > 0)
            {
                ctFont.AddNewB().val = (pr.GetBArray(0).val);
            }
            if (pr.SizeOfUArray() > 0)
            {
                ctFont.AddNewU().val = (pr.GetUArray(0).val);
            }
            if (pr.SizeOfIArray() > 0)
            {
                ctFont.AddNewI().val = (pr.GetIArray(0).val);
            }
            if (pr.SizeOfColorArray() > 0)
            {
                CT_Color c1 = pr.GetColorArray(0);
                CT_Color c2 = ctFont.AddNewColor();
                if (c1.IsSetAuto())
                {
                    c2.auto          = (c1.auto);
                    c2.autoSpecified = true;
                }
                if (c1.IsSetIndexed())
                {
                    c2.indexed          = (c1.indexed);
                    c2.indexedSpecified = true;
                }
                if (c1.IsSetRgb())
                {
                    c2.SetRgb(c1.GetRgb());
                    c2.rgbSpecified = true;
                }
                if (c1.IsSetTheme())
                {
                    c2.theme          = (c1.theme);
                    c2.themeSpecified = true;
                }
                if (c1.IsSetTint())
                {
                    c2.tint          = (c1.tint);
                    c2.tintSpecified = true;
                }
            }

            if (pr.SizeOfSzArray() > 0)
            {
                ctFont.AddNewSz().val = (pr.GetSzArray(0).val);
            }
            if (pr.SizeOfRFontArray() > 0)
            {
                ctFont.AddNewName().val = (pr.GetRFontArray(0).val);
            }
            if (pr.SizeOfFamilyArray() > 0)
            {
                ctFont.AddNewFamily().val = (pr.GetFamilyArray(0).val);
            }
            if (pr.sizeOfSchemeArray() > 0)
            {
                ctFont.AddNewScheme().val = (pr.GetSchemeArray(0).val);
            }
            if (pr.sizeOfCharsetArray() > 0)
            {
                ctFont.AddNewCharset().val = (pr.GetCharsetArray(0).val);
            }
            if (pr.sizeOfCondenseArray() > 0)
            {
                ctFont.AddNewCondense().val = (pr.GetCondenseArray(0).val);
            }
            if (pr.sizeOfExtendArray() > 0)
            {
                ctFont.AddNewExtend().val = (pr.GetExtendArray(0).val);
            }
            if (pr.sizeOfVertAlignArray() > 0)
            {
                ctFont.AddNewVertAlign().val = (pr.GetVertAlignArray(0).val);
            }
            if (pr.sizeOfOutlineArray() > 0)
            {
                ctFont.AddNewOutline().val = (pr.GetOutlineArray(0).val);
            }
            if (pr.sizeOfShadowArray() > 0)
            {
                ctFont.AddNewShadow().val = (pr.GetShadowArray(0).val);
            }
            if (pr.sizeOfStrikeArray() > 0)
            {
                ctFont.AddNewStrike().val = (pr.GetStrikeArray(0).val);
            }

            return(ctFont);
        }
示例#32
0
        public static CT_TextCharacterProperties Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_TextCharacterProperties ctObj = new CT_TextCharacterProperties();

            ctObj.kumimoji = XmlHelper.ReadBool(node.Attributes["kumimoji"]);
            ctObj.lang     = XmlHelper.ReadString(node.Attributes["lang"]);
            ctObj.altLang  = XmlHelper.ReadString(node.Attributes["altLang"]);
            ctObj.sz       = XmlHelper.ReadInt(node.Attributes["sz"]);
            if (node.Attributes["b"] != null)
            {
                ctObj.b = XmlHelper.ReadBool(node.Attributes["b"]);
            }
            if (node.Attributes["i"] != null)
            {
                ctObj.i = XmlHelper.ReadBool(node.Attributes["i"]);
            }
            if (node.Attributes["u"] != null)
            {
                ctObj.u = (ST_TextUnderlineType)Enum.Parse(typeof(ST_TextUnderlineType), node.Attributes["u"].Value);
            }
            if (node.Attributes["strike"] != null)
            {
                ctObj.strike = (ST_TextStrikeType)Enum.Parse(typeof(ST_TextStrikeType), node.Attributes["strike"].Value);
            }
            ctObj.kern = XmlHelper.ReadInt(node.Attributes["kern"]);
            if (node.Attributes["cap"] != null)
            {
                ctObj.cap = (ST_TextCapsType)Enum.Parse(typeof(ST_TextCapsType), node.Attributes["cap"].Value);
            }
            ctObj.spc        = XmlHelper.ReadInt(node.Attributes["spc"]);
            ctObj.normalizeH = XmlHelper.ReadBool(node.Attributes["normalizeH"]);
            ctObj.baseline   = XmlHelper.ReadInt(node.Attributes["baseline"]);
            ctObj.noProof    = XmlHelper.ReadBool(node.Attributes["noProof"]);
            if (node.Attributes["dirty"] != null)
            {
                ctObj.dirty = XmlHelper.ReadBool(node.Attributes["dirty"]);
            }
            ctObj.err = XmlHelper.ReadBool(node.Attributes["err"]);
            if (node.Attributes["smtClean"] != null)
            {
                ctObj.smtClean = XmlHelper.ReadBool(node.Attributes["smtClean"]);
            }
            ctObj.smtId = XmlHelper.ReadUInt(node.Attributes["smtId"]);
            ctObj.bmk   = XmlHelper.ReadString(node.Attributes["bmk"]);
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "ln")
                {
                    ctObj.ln = CT_LineProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "noFill")
                {
                    ctObj.noFill = new CT_NoFillProperties();
                }
                else if (childNode.LocalName == "solidFill")
                {
                    ctObj.solidFill = CT_SolidColorFillProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "gradFill")
                {
                    ctObj.gradFill = CT_GradientFillProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "blipFill")
                {
                    ctObj.blipFill = CT_BlipFillProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "pattFill")
                {
                    ctObj.pattFill = CT_PatternFillProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "grpFill")
                {
                    ctObj.grpFill = new CT_GroupFillProperties();
                }
                else if (childNode.LocalName == "effectLst")
                {
                    ctObj.effectLst = CT_EffectList.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "effectDag")
                {
                    ctObj.effectDag = CT_EffectContainer.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "highlight")
                {
                    ctObj.highlight = CT_Color.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "uLnTx")
                {
                    ctObj.uLnTx = new CT_TextUnderlineLineFollowText();
                }
                else if (childNode.LocalName == "uLn")
                {
                    ctObj.uLn = CT_LineProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "uFillTx")
                {
                    ctObj.uFillTx = new CT_TextUnderlineFillFollowText();
                }
                else if (childNode.LocalName == "uFill")
                {
                    ctObj.uFill = CT_TextUnderlineFillGroupWrapper.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "latin")
                {
                    ctObj.latin = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "ea")
                {
                    ctObj.ea = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "cs")
                {
                    ctObj.cs = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "sym")
                {
                    ctObj.sym = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "hlinkClick")
                {
                    ctObj.hlinkClick = CT_Hyperlink.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "hlinkMouseOver")
                {
                    ctObj.hlinkMouseOver = CT_Hyperlink.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "extLst")
                {
                    ctObj.extLst = CT_OfficeArtExtensionList.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }
示例#33
0
文件: Sheet.cs 项目: vardars/npoi
 public CT_DataBar()
 {
     this.colorField = new CT_Color();
     this.cfvoField = new List<CT_Cfvo>();
     this.minLengthField = ((uint)(10));
     this.maxLengthField = ((uint)(90));
     this.showValueField = true;
 }