zoukankan      html  css  js  c++  java
  • C# 导出Excel的单元格属性设置【转载】

    range.NumberFormatLocal = "@";     //设置单元格格式为文本   
    range = (Range)worksheet.get_Range("A1", "E1");     //获取Excel多个单元格区域:本例做为Excel表头   
    range.Merge(0);     //单元格合并动作   
    worksheet.Cells[1, 1] = "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;     //保存Excel的时候,不弹出是否保存的窗口直接进行保存

  • 相关阅读:
    Java自学笔记(21):【IO】数据流,标准输入输出
    makefile 学习笔记
    tensorflow 环境搭建
    matlab
    【转】MATLAB各种矩阵生成函数
    leetcode刷题收获
    leetcode 15. 3Sum
    STL 记录
    leetcode 服务器环境
    visual studio 2017 使用笔记
  • 原文地址:https://www.cnblogs.com/dekevin/p/2612848.html
Copyright © 2011-2022 走看看