本文整理汇总了C#中NPOI.XSSF.UserModel.XSSFColor.GetCTColor方法的典型用法代码示例。如果您正苦于以下问题:C# XSSFColor.GetCTColor方法的具体用法?C# XSSFColor.GetCTColor怎么用?C# XSSFColor.GetCTColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.XSSF.UserModel.XSSFColor
的用法示例。
在下文中一共展示了XSSFColor.GetCTColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetFillForegroundColor
/**
* Set the foreground fill color represented as a {@link XSSFColor} value.
* <br/>
* <i>Note: Ensure Foreground color is Set prior to background color.</i>
* @param color the color to use
* @see #setFillBackgroundColor(NPOI.xssf.usermodel.XSSFColor) )
*/
public void SetFillForegroundColor(XSSFColor color)
{
CT_Fill ct = GetCTFill();
CT_PatternFill ptrn = ct.GetPatternFill();
if (color == null)
{
if (ptrn != null) ptrn.unsetFgColor();
}
else
{
if (ptrn == null) ptrn = ct.AddNewPatternFill();
ptrn.fgColor =(color.GetCTColor());
}
int idx = _stylesSource.PutFill(new XSSFCellFill(ct));
_cellXf.fillId = (uint)idx;
_cellXf.applyFill = (true);
}
示例2: SetBottomBorderColor
/**
* Set the color to use for the bottom border
*
* @param color the color to use, null means no color
*/
public void SetBottomBorderColor(XSSFColor color)
{
CT_Border ct = GetCTBorder();
if (color == null && !ct.IsSetBottom()) return;
CT_BorderPr pr = ct.IsSetBottom() ? ct.bottom : ct.AddNewBottom();
if (color != null) pr.SetColor(color.GetCTColor());
else pr.UnsetColor();
int idx = _stylesSource.PutBorder(new XSSFCellBorder(ct, _theme));
_cellXf.borderId = (uint)idx;
_cellXf.applyBorder = (true);
}
示例3: TestGetSetFillBackgroundColor
public void TestGetSetFillBackgroundColor()
{
Assert.AreEqual(IndexedColors.Automatic.Index, cellStyle.FillBackgroundColor);
Assert.IsNull(cellStyle.FillBackgroundColorColor);
XSSFColor clr;
int num = stylesTable.GetFills().Count;
//setting indexed color
cellStyle.FillBackgroundColor = (IndexedColors.Red.Index);
Assert.AreEqual(IndexedColors.Red.Index, cellStyle.FillBackgroundColor);
clr = (XSSFColor)cellStyle.FillBackgroundColorColor;
Assert.IsTrue(clr.GetCTColor().IsSetIndexed());
Assert.AreEqual(IndexedColors.Red.Index, clr.Indexed);
//a new fill was Added to the styles table
Assert.AreEqual(num + 1, stylesTable.GetFills().Count);
//id of the Created border
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((uint)IndexedColors.Red.Index, ctFill.GetPatternFill().bgColor.indexed);
//setting XSSFColor
num = stylesTable.GetFills().Count;
clr = new XSSFColor(Color.Cyan);
cellStyle.SetFillBackgroundColor(clr); // TODO this testcase assumes that cellStyle creates a new CT_Fill, but the implementation changes the existing style. - do not know whats right 8-(
Assert.AreEqual(clr.GetCTColor().ToString(), ((XSSFColor)cellStyle.FillBackgroundColorColor).GetCTColor().ToString());
byte[] rgb = ((XSSFColor)cellStyle.FillBackgroundColorColor).GetRgb();
Assert.AreEqual(Color.Cyan.ToArgb(), Color.FromArgb(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF).ToArgb());
//another border was added to the styles table
Assert.AreEqual(num, stylesTable.GetFills().Count);
//passing null unsets the color
cellStyle.SetFillBackgroundColor(null);
Assert.IsNull(cellStyle.FillBackgroundColorColor);
Assert.AreEqual(IndexedColors.Automatic.Index, cellStyle.FillBackgroundColor);
}
示例4: TestGetSetRightBorderColor
public void TestGetSetRightBorderColor()
{
//defaults
Assert.AreEqual(IndexedColors.Black.Index, cellStyle.RightBorderColor);
Assert.IsNull(cellStyle.RightBorderXSSFColor);
int num = stylesTable.GetBorders().Count;
XSSFColor clr;
//setting indexed color
cellStyle.RightBorderColor = (IndexedColors.BlueGrey.Index);
Assert.AreEqual(IndexedColors.BlueGrey.Index, cellStyle.RightBorderColor);
clr = cellStyle.RightBorderXSSFColor;
Assert.IsTrue(clr.GetCTColor().IsSetIndexed());
Assert.AreEqual(IndexedColors.BlueGrey.Index, clr.Indexed);
//a new border was Added to the styles table
Assert.AreEqual(num + 1, stylesTable.GetBorders().Count);
//id of the Created border
int borderId = (int)cellStyle.GetCoreXf().borderId;
Assert.IsTrue(borderId > 0);
//check Changes in the underlying xml bean
CT_Border ctBorder = stylesTable.GetBorderAt(borderId).GetCTBorder();
Assert.AreEqual((uint)IndexedColors.BlueGrey.Index, ctBorder.right.color.indexed);
//setting XSSFColor
num = stylesTable.GetBorders().Count;
clr = new XSSFColor(Color.Cyan);
cellStyle.SetRightBorderColor(clr);
Assert.AreEqual(clr.GetCTColor().ToString(), cellStyle.RightBorderXSSFColor.GetCTColor().ToString());
byte[] rgb = cellStyle.RightBorderXSSFColor.GetRgb();
Assert.AreEqual(Color.Cyan.ToArgb(), Color.FromArgb(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF).ToArgb());
//another border was Added to the styles table
Assert.AreEqual(num, stylesTable.GetBorders().Count);
//passing null unsets the color
cellStyle.SetRightBorderColor(null);
Assert.IsNull(cellStyle.RightBorderXSSFColor);
}
示例5: InheritFromThemeAsRequired
/**
* If the colour is based on a theme, then inherit
* information (currently just colours) from it as
* required.
*/
public void InheritFromThemeAsRequired(XSSFColor color)
{
if (color == null)
{
// Nothing for us to do
return;
}
if (!color.GetCTColor().themeSpecified)
{
// No theme Set, nothing to do
return;
}
// Get the theme colour
XSSFColor themeColor = GetThemeColor(color.Theme);
// Set the raw colour, not the adjusted one
// Do a raw Set, no adjusting at the XSSFColor layer either
color.GetCTColor().SetRgb(themeColor.GetCTColor().GetRgb());
// All done
}
示例6: SetBorderColor
/**
* Set the color to use for the selected border
*
* @param side - where to apply the color defInition
* @param color - the color to use
*/
public void SetBorderColor(BorderSide side, XSSFColor color)
{
CT_BorderPr borderPr = GetBorder(side, true);
if (color == null) borderPr.UnsetColor();
else
borderPr.color = color.GetCTColor();
}