Пример #1
0
        public void Test44916()
        {
            HSSFWorkbook wb = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sheet = wb.CreateSheet();

            // 1. Create drawing patriarch
            Drawing patr = sheet.CreateDrawingPatriarch();

            // 2. Try to re-get the patriarch
            Drawing existingPatr;

            try
            {
                existingPatr = sheet.DrawingPatriarch;
            }
            catch (NullReferenceException e)
            {
                throw new AssertFailedException("Identified bug 44916");
            }

            // 3. Use patriarch
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 245, (short)1, 1, (short)1, 2);

            anchor.AnchorType = (3);
            byte[] pictureData = HSSFTestDataSamples.GetTestDataFileContent("logoKarmokar4.png");
            int    idx1        = wb.AddPicture(pictureData, PictureType.PNG);

            patr.CreatePicture(anchor, idx1);

            // 4. Try to re-use patriarch later
            existingPatr = sheet.DrawingPatriarch;
            Assert.IsNotNull(existingPatr);
        }
Пример #2
0
        public void SetUp()
        {
            workbook = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sheet = workbook.CreateSheet("Test");
            patriarch    = (HSSFPatriarch)sheet.CreateDrawingPatriarch();
            escherGroupA = patriarch.CreateGroup(new HSSFClientAnchor(0, 0, 1022, 255, (short)0, 0, (short)0, 0));
            escherGroupB = patriarch.CreateGroup(new HSSFClientAnchor(20, 30, 500, 200, (short)0, 0, (short)0, 0));
            //        escherGroup = new HSSFShapeGroup(null, new HSSFChildAnchor());
            graphics = new EscherGraphics(this.escherGroupA, workbook, Color.Black, 1.0f);
        }
Пример #3
0
        public void TestBasic()
        {
            HSSFWorkbook wb = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sheet = wb.CreateSheet();

            Drawing patr = sheet.CreateDrawingPatriarch();

            Assert.IsNotNull(patr);

            // assert something more interesting
        }
Пример #4
0
        public void Test45829()
        {
            HSSFWorkbook wb = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sh1 = wb.CreateSheet();
            Drawing p1 = sh1.CreateDrawingPatriarch();

            byte[]  pictureData = HSSFTestDataSamples.GetTestDataFileContent("45829.png");
            int     idx1        = wb.AddPicture(pictureData, PictureType.PNG);
            Picture pic         = p1.CreatePicture(new HSSFClientAnchor(), idx1);

            pic.Resize();
        }
Пример #5
0
        public void TestAlignment()
        {
            HSSFWorkbook wb = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sh1 = wb.CreateSheet();
            Drawing patriarch           = sh1.CreateDrawingPatriarch();

            Textbox            textbox = patriarch.CreateTextbox(new HSSFClientAnchor(0, 0, 0, 0, 1, 1, 6, 4));
            HSSFRichTextString str     = new HSSFRichTextString("Hello, World");

            textbox.String = (str);
            textbox.HorizontalAlignment = (HSSFTextbox.HORIZONTAL_ALIGNMENT_CENTERED);
            textbox.VerticalAlignment   = (HSSFTextbox.VERTICAL_ALIGNMENT_CENTER);

            Assert.AreEqual(HSSFTextbox.HORIZONTAL_ALIGNMENT_CENTERED, textbox.HorizontalAlignment);
            Assert.AreEqual(HSSFTextbox.VERTICAL_ALIGNMENT_CENTER, textbox.VerticalAlignment);
        }
Пример #6
0
        public void TestSetDeafultTextFormat()
        {
            HSSFWorkbook wb = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sheet = wb.CreateSheet();
            Drawing patriarch             = sheet.CreateDrawingPatriarch();

            Textbox            textbox1 = patriarch.CreateTextbox(new HSSFClientAnchor(0, 0, 0, 0, 1, 1, 3, 3));
            HSSFRichTextString rt1      = new HSSFRichTextString("Hello, World!");

            Assert.AreEqual(0, rt1.NumFormattingRuns);
            textbox1.String = (rt1);

            HSSFRichTextString rt2 = (HSSFRichTextString)textbox1.String;

            Assert.AreEqual(1, rt2.NumFormattingRuns);
            Assert.AreEqual(HSSFRichTextString.NO_FONT, rt2.GetFontOfFormattingRun(0));
        }
Пример #7
0
        public void TestResize()
        {
            HSSFWorkbook wb = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sh1 = wb.CreateSheet();
            Drawing p1 = sh1.CreateDrawingPatriarch();

            byte[]       pictureData = HSSFTestDataSamples.GetTestDataFileContent("logoKarmokar4.png");
            int          idx1        = wb.AddPicture(pictureData, PictureType.PNG);
            Picture      picture1    = p1.CreatePicture(new HSSFClientAnchor(), idx1);
            ClientAnchor anchor1     = picture1.GetPreferredSize();

            //assert against what would BiffViewer print if we insert the image in xls and dump the file
            Assert.AreEqual(0, anchor1.Col1);
            Assert.AreEqual(0, anchor1.Row1);
            Assert.AreEqual(1, anchor1.Col2);
            Assert.AreEqual(9, anchor1.Row2);
            Assert.AreEqual(0, anchor1.Dx1);
            Assert.AreEqual(0, anchor1.Dy1);
            Assert.AreEqual(848, anchor1.Dx2);
            Assert.AreEqual(240, anchor1.Dy2);
        }