Ejemplo n.º 1
0
        /// <summary>
        /// Gets the HTML string representing this horizontal alignment.
        /// </summary>
        /// <param name="style">The horizontal alignment.</param>
        /// <returns>The related string.</returns>
        private static String GetAlignString(HorizontalAlignmentStyle style)
        {
            switch (style)
            {
            case HorizontalAlignmentStyle.Left:
                return("left");

            case HorizontalAlignmentStyle.Center:
                return("center");

            case HorizontalAlignmentStyle.Right:
                return("right");
            }
            return("");
        }
Ejemplo n.º 2
0
 public CellStyleData(CellStyleCachedCollection parentCollection, bool isDefault)
     : base(parentCollection, isDefault)
 {
     this.HorizontalAlignment    = HorizontalAlignmentStyle.General;
     this.VerticalAlignment      = VerticalAlignmentStyle.Bottom;
     this.PatternStyle           = FillPatternStyle.None;
     this.PatternBackgroundColor = Color.White;
     this.PatternForegroundColor = Color.Black;
     this.Locked       = true;
     this.NumberFormat = string.Empty;
     this.FontData     = new ExcelFontData();
     this.BorderColor  = new Color[] { Color.Black, Color.Black, Color.Black, Color.Black, Color.Black };
     this.BorderStyle  = new LineStyle[5];
     this.BordersUsed  = MultipleBorders.None;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Get element extents by view and apply offset vector
        /// </summary>
        /// <param name="element"></param>
        /// <param name="view"></param>
        /// <param name="offset"></param>
        /// <param name="verticalAlignment"></param>
        /// <param name="horizontalAlignment"></param>
        /// <returns></returns>
        private static XYZ GetExtentsWithOffset(Element element, View view, XYZ offset, VerticalAlignmentStyle verticalAlignment, HorizontalAlignmentStyle horizontalAlignment)
        {
            var box = GetElementExtentsByView(element, view);

            if (box != null)
            {
                double X, Y, Z = 0;

                switch (verticalAlignment)
                {
                case VerticalAlignmentStyle.Bottom: Y = box.Min.Y; break;

                case VerticalAlignmentStyle.Top: Y = box.Max.Y; break;

                default: Y = box.Min.Y + ((box.Max.Y - box.Min.Y) / 2); break;
                }

                switch (horizontalAlignment)
                {
                case HorizontalAlignmentStyle.Left: X = box.Min.X; break;

                case HorizontalAlignmentStyle.Right: X = box.Max.X; break;

                default: X = box.Min.X + ((box.Max.X - box.Min.X) / 2); break;
                }

                return(new XYZ(X + offset.X, Y + offset.Y, Z + offset.Z));
            }
            else
            {
                XYZ location = GetLocationPoint(element);
                return(new XYZ(location.X + offset.X, location.Y + offset.Y, location.Z + offset.Z));
            }
        }
        /// <summary>
        /// Format the Cell
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="workSheet"></param>
        /// <param name="vertical"></param>
        /// <param name="horizontal"></param>
        /// <param name="weight"></param>
        /// <param name="isWrap"></param>
        /// <param name="backgroundColor"></param>
        /// <param name="isTextVertical"></param>
        private void GetFormatedCell(int row, int col, ref ExcelWorksheet workSheet,
                                    VerticalAlignmentStyle vertical = VerticalAlignmentStyle.Center,
                                    HorizontalAlignmentStyle horizontal = HorizontalAlignmentStyle.Center,
                                    int weight = ExcelFont.NormalWeight, bool isWrap = default(bool), Color backgroundColor = default(Color),
                                    bool isTextVertical = default(bool), Color foregroundColor = default(Color), int rotation = default(int))
        {
            workSheet.Cells[row, col].Style.VerticalAlignment = vertical;
            workSheet.Cells[row, col].Style.HorizontalAlignment = horizontal;
            workSheet.Cells[row, col].Style.Font.Weight = weight;
            workSheet.Cells[row, col].Style.IsTextVertical = isTextVertical;
            //if (backgroundColor != default(Color) || foregroundColor != default(Color))
            //    workSheet.Cells[row, col].Style.FillPattern.SetPattern(FillPatternStyle.None, foregroundColor, backgroundColor);
            if (isWrap)
                workSheet.Cells[row, col].Style.WrapText = true;
            else
                workSheet.Columns[col].AutoFit();

            if (rotation != default(int))
                workSheet.Cells[row, col].Style.Rotation = rotation;
        }