Пример #1
0
        /// <summary>
        /// Constructs a textbox Under the patriarch.
        /// </summary>
        /// <param name="anchor">the client anchor describes how this Group is attached
        /// to the sheet.</param>
        /// <returns>the newly Created textbox.</returns>
        public HSSFSimpleShape CreateTextbox(IClientAnchor anchor)
        {
            HSSFTextbox shape = new HSSFTextbox(null, (HSSFAnchor)anchor);

            shape.Anchor = (HSSFAnchor)anchor;
            AddShape(shape);
            return(shape);
        }
Пример #2
0
        /// <summary>
        /// Create a new textbox Under this Group.
        /// </summary>
        /// <param name="anchor">the position of the shape.</param>
        /// <returns>the textbox</returns>
        public HSSFTextbox CreateTextbox(HSSFChildAnchor anchor)
        {
            HSSFTextbox shape = new HSSFTextbox(this, anchor);

            shape.Anchor = anchor;
            shapes.Add(shape);
            return(shape);
        }
Пример #3
0
        public void DrawString(String str, int x, int y)
        {
            if (string.IsNullOrEmpty(str))
            {
                return;
            }

            using (Font excelFont = new Font(font.Name.Equals("SansSerif") ? "Arial" : font.Name, (int)(font.Size / verticalPixelsPerPoint), font.Style))
            {
                FontDetails d      = StaticFontMetrics.GetFontDetails(excelFont);
                int         width  = (int)((d.GetStringWidth(str) * 8) + 12);
                int         height = (int)((font.Size / verticalPixelsPerPoint) + 6) * 2;
                y -= Convert.ToInt32((font.Size / verticalPixelsPerPoint) + 2 * verticalPixelsPerPoint);    // we want to Draw the shape from the top-left
                HSSFTextbox textbox = escherGroup.CreateTextbox(new HSSFChildAnchor(x, y, x + width, y + height));
                textbox.IsNoFill  = (true);
                textbox.LineStyle = LineStyle.None;
                HSSFRichTextString s        = new HSSFRichTextString(str);
                HSSFFont           hssfFont = MatchFont(excelFont);
                s.ApplyFont(hssfFont);
                textbox.String = (s);
            }
        }