示例#1
0
        /// <summary>
        /// 获取完成头
        /// </summary>
        /// <returns></returns>
        public string GetHeader()
        {
            // 创建顶部和底部分隔线
            string top_DownDividerdivider = FinalColumnWides.GetTopAndDwon(FormatInfo.AngleStr, ColumnBlankNum);
            // 创建分隔线
            string divider = FinalColumnWides.GetDivider(FormatInfo.AngleStr, ColumnBlankNum);
            // 获取标题字符串
            string tilte = FinalColumnWides.GetTitleStr(TitleString, ColumnBlankNum, FormatInfo.DelimiterStr);
            // 得到头部字符串
            string headers = ColumnShowFormats.FillFormatTostring(Columns.ToArray(), FormatInfo.DelimiterStr, ColumnBlankNum);

            //绘制表格头
            StringBuilder top = new();

            if (FormatInfo.IsShowTop_Down_DataBorder)
            {
                top.AppendLine(top_DownDividerdivider);
            }
            if (!string.IsNullOrWhiteSpace(tilte))
            {
                top.AppendLine(tilte);
                top.AppendLine(divider);
            }
            top.AppendLine(headers);
            top.AppendLine(divider);
            return(top.ToString().Trim());
        }
示例#2
0
        /// <summary>
        /// 获取新行数据
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        public string GetNewRow(string[] row)
        {
            if (row is null)
            {
                return("");
            }

            Rows.Add(row);
            //内容
            StringBuilder data = new();

            if (Rows.Count > 1)
            {
                data.AppendLine(FinalColumnWides.GetDivider(FormatInfo.AngleStr, ColumnBlankNum));
            }
            data.AppendLine(ColumnShowFormats.FillFormatTostring(row, FormatInfo.DelimiterStr, ColumnBlankNum));
            return(data.ToString().Trim());
        }
示例#3
0
        /// <summary>
        /// 获取现有数据
        /// </summary>
        /// <returns></returns>
        public string GetExistData()
        {
            // 创建分隔线
            string divider = FinalColumnWides.GetDivider(FormatInfo.AngleStr, ColumnBlankNum);
            // 得到每行数据的字符串
            List <string> rowStrs = Rows.Select(row => ColumnShowFormats.FillFormatTostring(row, FormatInfo.DelimiterStr, ColumnBlankNum)).ToList();
            StringBuilder data    = new();

            for (int i = 0; i < rowStrs.Count; i++)
            {
                if (FormatInfo.IsShowTop_Down_DataBorder && i != 0)
                {
                    data.AppendLine(divider);
                }
                data.AppendLine(rowStrs[i]);
            }
            return(data.ToString().Trim());
        }