示例#1
0
        public void TestRichTextFontAndColor()
        {
            XSSFWorkbook wb      = new XSSFWorkbook();
            XSSFSheet    sheet   = wb.CreateSheet() as XSSFSheet;
            XSSFDrawing  Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;

            XSSFTextBox        shape = Drawing.CreateTextbox(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4)) as XSSFTextBox;
            XSSFRichTextString rt    = new XSSFRichTextString("Test String");

            XSSFFont font = wb.CreateFont() as XSSFFont;

            font.SetColor(new XSSFColor(Color.FromRgb(0, 128, 128)));
            font.FontName = ("Arial");
            rt.ApplyFont(font);

            shape.SetText(rt);

            CT_TextParagraph pr = shape.GetCTShape().txBody.GetPArray(0);

            Assert.AreEqual(1, pr.SizeOfRArray());

            CT_TextCharacterProperties rPr = pr.GetRArray(0).rPr;

            Assert.AreEqual("Arial", rPr.latin.typeface);
            Assert.IsTrue(Arrays.Equals(
                              new byte[] { 0, (byte)128, (byte)128 },
                              rPr.solidFill.srgbClr.val));

            checkRewrite(wb);
            wb.Close();
        }
示例#2
0
        public void TestRichText()
        {
            XSSFWorkbook wb      = new XSSFWorkbook();
            XSSFSheet    sheet   = wb.CreateSheet() as XSSFSheet;
            XSSFDrawing  Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;

            XSSFTextBox        shape = Drawing.CreateTextbox(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4)) as XSSFTextBox;
            XSSFRichTextString rt    = new XSSFRichTextString("Test String");

            XSSFFont font = wb.CreateFont() as XSSFFont;

            font.SetColor(new XSSFColor(Color.FromRgb(0, 128, 128)));
            font.IsItalic  = (true);
            font.IsBold    = (true);
            font.Underline = FontUnderlineType.Single;
            rt.ApplyFont(font);

            shape.SetText(rt);

            CT_TextParagraph pr = shape.GetCTShape().txBody.p[0];

            Assert.AreEqual(1, pr.SizeOfRArray());

            CT_TextCharacterProperties rPr = pr.r[0].rPr;

            Assert.AreEqual(true, rPr.b);
            Assert.AreEqual(true, rPr.i);
            Assert.AreEqual(ST_TextUnderlineType.sng, rPr.u);
            Assert.IsTrue(Arrays.Equals(
                              new byte[] { 0, (byte)128, (byte)128 },
                              rPr.solidFill.srgbClr.val));

            checkRewrite(wb);
            wb.Close();
        }