• range.NumberFormatLocal = "@";     //设置单元格格式为文本   
  •   
  • range = (Range)worksheet.get_Range("A1""E1");     //获取Excel多个单元格区域:本例做为Excel表头   
  •   
  • range.Merge(0);     //单元格合并动作   
  •   
  • worksheet.Cells[11] = "Excel单元格赋值";     //Excel单元格赋值   
  •   
  • range.Font.Size = 15;     //设置字体大小   
  •   
  • range.Font.Underline=true;     //设置字体是否有下划线   
  •   
  • range.Font.Name="黑体";       设置字体的种类   
  •   
  • range.HorizontalAlignment=XlHAlign.xlHAlignCenter;     //设置字体在单元格内的对其方式   
  •   
  • range.ColumnWidth=15;     //设置单元格的宽度   
  •   
  • range.Cells.Interior.Color=System.Drawing.Color.FromArgb(255,204,153).ToArgb();     //设置单元格的背景色   
  •   
  • range.Borders.LineStyle=1;     //设置单元格边框的粗细   
  •   
  • range.BorderAround(XlLineStyle.xlContinuous,XlBorderWeight.xlThick,XlColorIndex.xlColorIndexAutomatic,System.Drawing.Color.Black.ToArgb());     //给单元格加边框   
  •   
  • range.Borders.get_Item(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone; //设置单元格上边框为无边框   
  •   
  •     range.EntireColumn.AutoFit();     //自动调整列宽   
  •   
  • Range.HorizontalAlignment= xlCenter;     // 文本水平居中方式   
  •   
  • Range.VerticalAlignment= xlCenter     //文本垂直居中方式   
  •   
  • Range.WrapText=true;     //文本自动换行   
  •   
  • Range.Interior.ColorIndex=39;     //填充颜色为淡紫色   
  •   
  • Range.Font.Color=clBlue;     //字体颜色   
  •   
  • xlsApp.DisplayAlerts=false;     

相关文章:

  • 2022-12-23
  • 2022-02-19
  • 2021-12-22
  • 2022-01-07
  • 2021-12-04
  • 2022-01-31
  • 2022-12-23
猜你喜欢
  • 2021-08-16
  • 2021-09-12
  • 2021-11-20
  • 2021-10-23
  • 2021-11-30
  • 2022-12-23
  • 2021-08-29
相关资源
相似解决方案