ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

C# 画图表

2022-06-15 16:31:36  阅读:168  来源: 互联网

标签:Rows C# Cells tableFontSize 图表 FontSize Paragraphs First


引用DocX

 

protected double bodyFontSize = 12d;
protected float lineSpacing = 1.5f;
protected float indentationFirstLine = 1f;
protected double tableFontSize = 10d;


  using (var document = DocX.Create(@"Toc2.docx")) {
document.InsertParagraph("技术参数").Font("宋体").FontSize(bodyFontSize); var columnWidths = new float[] { 150f, 180f, 150f, 150f }; var t = document.InsertTable(15, columnWidths.Length); t.SetWidths(columnWidths); t.Design = TableDesign.TableGrid; t.Alignment = Alignment.center; for (int i = 0; i < t.RowCount; i++) { for (int j = 0; j < t.ColumnCount; j++) { t.Rows[i].Cells[j].Paragraphs.First().Font("宋体").FontSize(8).Alignment = Alignment.center; t.Rows[i].Cells[j].VerticalAlignment = VerticalAlignment.Center; } } var row = t.Rows.First(); t.Rows[0].MergeCells(1, 2); t.Rows[0].Cells[1].Width = 330f; row.Cells[0].Paragraphs.First().Append("基坑类别").FontSize(tableFontSize); row.Cells[1].Paragraphs.First().Append("施工进度").FontSize(tableFontSize); row.Cells[2].Paragraphs.First().Append("监测频率").FontSize(tableFontSize); t.MergeCellsInColumn(0, 1, 7);//第几列,开始,结束 t.Rows[1].Cells[0].Paragraphs.First().Append(string.Format("一级")).FontSize(tableFontSize); t.MergeCellsInColumn(0, 8, 14); t.Rows[8].Cells[0].Paragraphs.First().Append(string.Format("二级")).FontSize(tableFontSize); t.MergeCellsInColumn(1, 1, 3);//第几列,开始,结束 t.Rows[1].Cells[1].Paragraphs.First().Append(string.Format("开挖深度h")).FontSize(tableFontSize); t.MergeCellsInColumn(1, 4, 7);//第几列,开始,结束 t.Rows[4].Cells[1].Paragraphs.First().Append(string.Format("底板浇筑后时间(d)")).FontSize(tableFontSize); t.MergeCellsInColumn(1, 8, 10);//第几列,开始,结束 t.Rows[8].Cells[1].Paragraphs.First().Append(string.Format("开挖深度h1")).FontSize(tableFontSize); t.MergeCellsInColumn(1, 11, 14);//第几列,开始,结束 t.Rows[11].Cells[1].Paragraphs.First().Append(string.Format("底板浇筑后时间(d)")).FontSize(tableFontSize); t.Rows[1].Cells[2].Paragraphs.First().Append(string.Format("≤H/3")).FontSize(tableFontSize); t.Rows[1].Cells[3].Paragraphs.First().Append(string.Format("1次/3d")).FontSize(tableFontSize); t.Rows[2].Cells[2].Paragraphs.First().Append(string.Format("H/3~2H/3")).FontSize(tableFontSize); t.Rows[2].Cells[3].Paragraphs.First().Append(string.Format("1次/2d")).FontSize(tableFontSize); t.Rows[3].Cells[2].Paragraphs.First().Append(string.Format("2H/3~H")).FontSize(tableFontSize); t.Rows[3].Cells[3].Paragraphs.First().Append(string.Format("1次/d")).FontSize(tableFontSize); t.Rows[4].Cells[2].Paragraphs.First().Append(string.Format("≤7")).FontSize(tableFontSize); t.Rows[4].Cells[3].Paragraphs.First().Append(string.Format("1次/d")).FontSize(tableFontSize); t.Rows[5].Cells[2].Paragraphs.First().Append(string.Format("7~14")).FontSize(tableFontSize); t.Rows[5].Cells[3].Paragraphs.First().Append(string.Format("1次/3d")).FontSize(tableFontSize); t.Rows[6].Cells[2].Paragraphs.First().Append(string.Format("14~28")).FontSize(tableFontSize); t.Rows[6].Cells[3].Paragraphs.First().Append(string.Format("1次/5d")).FontSize(tableFontSize); t.Rows[7].Cells[2].Paragraphs.First().Append(string.Format(">28")).FontSize(tableFontSize); t.Rows[7].Cells[3].Paragraphs.First().Append(string.Format("1次/7d")).FontSize(tableFontSize); t.Rows[8].Cells[2].Paragraphs.First().Append(string.Format("≤H/3")).FontSize(tableFontSize); t.Rows[8].Cells[3].Paragraphs.First().Append(string.Format("1次/2d")).FontSize(tableFontSize); t.Rows[9].Cells[2].Paragraphs.First().Append(string.Format("H/3~2H/3")).FontSize(tableFontSize); t.Rows[9].Cells[3].Paragraphs.First().Append(string.Format("1次/5d")).FontSize(tableFontSize); t.Rows[10].Cells[2].Paragraphs.First().Append(string.Format("2H/3~H")).FontSize(tableFontSize); t.Rows[10].Cells[3].Paragraphs.First().Append(string.Format("1次/d")).FontSize(tableFontSize); t.Rows[11].Cells[2].Paragraphs.First().Append(string.Format("≤7")).FontSize(tableFontSize); t.Rows[11].Cells[3].Paragraphs.First().Append(string.Format("1次/2d")).FontSize(tableFontSize); t.Rows[12].Cells[2].Paragraphs.First().Append(string.Format("7~14")).FontSize(tableFontSize); t.Rows[12].Cells[3].Paragraphs.First().Append(string.Format("1次/3d")).FontSize(tableFontSize); t.Rows[13].Cells[2].Paragraphs.First().Append(string.Format("14~28")).FontSize(tableFontSize); t.Rows[13].Cells[3].Paragraphs.First().Append(string.Format("1次/7d")).FontSize(tableFontSize); t.Rows[14].Cells[2].Paragraphs.First().Append(string.Format(">28")).FontSize(tableFontSize); t.Rows[14].Cells[3].Paragraphs.First().Append(string.Format("1次/10d")).FontSize(tableFontSize); document.InsertParagraph("注:(1) h——基坑开挖深度;H——基坑设计深度").Font("宋体").FontSize(bodyFontSize); document.InsertParagraph(" (2) 支撑结构开始拆除到拆除完成后3d内监测频率加密为1次/d。").Font("宋体").FontSize(bodyFontSize); document.InsertParagraph(" (3) 基坑工程施工至开挖前的监测频率视具体情况确定。").Font("宋体").FontSize(bodyFontSize); //----------------------------------------------------------------------------------------------------------------------------------------------------------------

document.InsertParagraph("技术参数").Font("宋体").FontSize(bodyFontSize).SpacingBefore(15);


columnWidths = new float[] { 150f, 180f, 150f };
t = document.InsertTable(5, columnWidths.Length);
t.SetWidths(columnWidths);
t.Design = TableDesign.TableGrid;
t.Alignment = Alignment.center;
for (int i = 0; i < t.RowCount; i++)
{
for (int j = 0; j < t.ColumnCount; j++)
{
t.Rows[i].Cells[j].Paragraphs.First().Font("宋体").FontSize(8).Alignment = Alignment.center;
t.Rows[i].Cells[j].VerticalAlignment = VerticalAlignment.Center;
}
}
row = t.Rows.First();
row.Cells[0].Paragraphs.First().Append("指标").FontSize(tableFontSize);
row.Cells[1].Paragraphs.First().Append("配套产品").FontSize(tableFontSize);
row.Cells[2].Paragraphs.First().Append("安装方式").FontSize(tableFontSize);


t.MergeCellsInColumn(1, 1, 4);
t.Rows[1].Cells[0].Paragraphs.First().Append("最大量程(mm):200 ~ 2000").FontSize(tableFontSize);
t.Rows[1].Cells[1].Paragraphs.First().Append("4芯传感器信号线缆智能无线采集终").FontSize(tableFontSize).Alignment = Alignment.center;
t.Rows[1].Cells[2].Paragraphs.First().Append("保护外壳+螺栓固定").FontSize(tableFontSize);
t.MergeCellsInColumn(2, 1, 4);
t.Rows[2].Cells[0].Paragraphs.First().Append("分辨率(mm): 0.02").FontSize(tableFontSize);
t.Rows[3].Cells[0].Paragraphs.First().Append("精度(F.S.):0.15 %").FontSize(tableFontSize);
t.Rows[4].Cells[0].Paragraphs.First().Append("工作温度(℃): -20 ~ 80").FontSize(tableFontSize);


               


                document.Save();
}

 

 

 

 

标签:Rows,C#,Cells,tableFontSize,图表,FontSize,Paragraphs,First
来源: https://www.cnblogs.com/lvqianqian/p/16378907.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有