Пример #1
0
        /// <summary>
        /// Writes a error comment for specified cell.
        /// </summary>
        /// <param name="cell">Cell to try apply specified comment.</param>
        /// <param name="value">Reference to value information.</param>
        public static void AddErrorComment(this ExcelRangeBase cell, FieldValueInformation value)
        {
            SentinelHelper.ArgumentNull(cell, nameof(cell));
            SentinelHelper.ArgumentNull(value, nameof(value));

            var comment = value.Comment;

            if (comment == null)
            {
                return;
            }

            var showComment = comment.Show == YesNo.Yes;

            if (!showComment)
            {
                return;
            }

            var font         = comment.Font;
            var text         = $"{comment.Text} {value.Value}";
            var autorComment = $"{Environment.MachineName}\\{Environment.UserName}";

            var cellComment = cell.AddComment(text, autorComment);

            cellComment.Font.Size      = font.Size;
            cellComment.Font.FontName  = font.Name;
            cellComment.Font.Color     = font.GetColor();
            cellComment.Font.Bold      = font.Bold == YesNo.Yes;
            cellComment.Font.Italic    = font.Italic == YesNo.Yes;
            cellComment.Font.UnderLine = font.Underline == YesNo.Yes;
        }
        /// <summary>
        /// Writes a error comment for specified cell.
        /// </summary>
        /// <param name="cell">Cell to try apply specified comment.</param>
        /// <param name="value">Reference to value information.</param>
        public static void AddErrorComment(this ExcelRangeBase cell, FieldValueInformation value)
        {
            SentinelHelper.ArgumentNull(cell);
            SentinelHelper.ArgumentNull(value);

            var comment = value.Comment;

            if (comment == null)
            {
                return;
            }

            var showComment = comment.Show == YesNo.Yes;

            if (!showComment)
            {
                return;
            }

            var font         = comment.Font;
            var text         = string.Format(CultureInfo.InvariantCulture, "{0} {1}", comment.Text, value.Value);
            var autorComment = string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", Environment.MachineName, Environment.UserName);

            var cellComment = cell.AddComment(text, autorComment);

            cellComment.Font.Size      = font.Size;
            cellComment.Font.FontName  = font.Name;
            cellComment.Font.Color     = font.GetColor();
            cellComment.Font.Bold      = font.Bold == YesNo.Yes;
            cellComment.Font.Italic    = font.Italic == YesNo.Yes;
            cellComment.Font.UnderLine = font.Underline == YesNo.Yes;
        }