C#设置Excel⾏⾼、列宽
设置固定值 worksheet.Columns[1].ColumnWidth = 15;
设置⾃动换⾏ worksheet.Columns.WrapText = true;
设置⾃动⾏⾼、列宽
xlApp.Columns.AutoFit();
xlApp.Rows.AutoFit();
对齐⽅式
worksheet.Columns.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft; // 对齐⽅式
或
worksheet.Columns[3].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft; // 对齐⽅式
其它
•sheet.Range["A1", "F" + (c + 2)].Borders.LineStyle = 1; // 边框粗细一张旧照片作文>刘吉桦
•sheet.Range["A1", "F" + (c + 2)].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; // 对齐⽅式
小米扫地机器人>七夕节古诗大全50首•sheet.Range["A1", "F1"].MergeCells = true; // 合并单元格
•sheet.Range["A1", "F2"].Font.Bold = true; // 加粗广东2019高考分数线
•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)); // 单元格背景颜⾊
发布评论