首页 > Windows开发 > 详细

C#设置Excel行高、列宽

时间:2019-08-17 01:41:57      阅读:298      评论:0      收藏:0      [点我收藏+]

设置固定值 worksheet.Columns[1].ColumnWidth = 15;

 

设置自动行高、列宽

 xlApp.Columns.AutoFit();
 xlApp.Rows.AutoFit();

 

其它

•sheet.Range["A1", "F" + (c + 2)].Borders.LineStyle = 1;  // 边框粗细

•sheet.Range["A1", "F" + (c + 2)].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; // 对齐方式

•sheet.Range["A1", "F1"].MergeCells = true;  // 合并单元格

•sheet.Range["A1", "F2"].Font.Bold = true;  // 加粗

•sheet.Range["A1", "F1"].Font.Size = 13;  // 字号

•sheet.Range["A1", "F" + (c + 2)].Font.Size = 11;

•sheet.Range["A1", "F" + (c + 2)].RowHeight = 21;  // 行高

•sheet.Range["A1"].RowHeight = 35;

•sheet.Range["A1", "F1"].ColumnWidth = 17;  // 列宽

•sheet.Range["B1"].ColumnWidth = 20;

•sheet.Range["A2", "F2"].Interior.Color = System.Drawing.ColorTranslator.ToOle(Color.FromArgb(197, 217, 241));  // 单元格背景颜色

 

C#设置Excel行高、列宽

原文:https://www.cnblogs.com/mol1995/p/11366709.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!