如题,请大侠指点一二~~谢谢!

解决方案 »

  1.   

    关注呀.
    不过如果是我,就用一个变通的办法先对付.
    建立一个只有标头的EXCEL文件,设好颜色和字体;
    然后再将数据导进去.
      

  2.   

    EXCEL是一个类嘛,里面有颜色,字体,表格线,等等属性呀
      

  3.   

    不好意思打扰一下,在csdn中如何发表我的帖子,一直找不到
      

  4.   

    /// <summary>
    /// 创建EXCEL对象
    /// </summary>
    private Excel.Application objectexcel    = null;
    /// <summary>
    /// 声明Excel.Workbook
    /// </summary>
    private Excel.Workbook    objectWorkbook = null;
    /// <summary>
    /// 声明Excel.WorkSheet
    /// </summary>
    private Excel.Worksheet   objectSheet   = null;try
    {
    objectexcel = new Excel.Application();
    //-------------打开Excel模版
    objectexcel.Workbooks.Open(ExcelTemplate,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);
    //-------------设置属性
    objectexcel.DisplayAlerts = false;
    //--------------
    objectexcel.Application.Visible =false;
    //----------
    //---------
    objectWorkbook   = objectexcel.ActiveWorkbook;
    //----------

    objectSheet     = (Excel.Worksheet)objectWorkbook.Sheets[SheetsIndex];
    }
    catch(Exception s)
    {
    WriteFileLog(s.Message);
    }///------------------------
    //---------设置背景颜色 
    objectSheet.get_Range(objectSheet.Cells[RowIndex,ColumnIndex],objectSheet.Cells[RowIndex,ColumnIndex]).Cells.Interior.Color =Color;
    //---设置字体颜色
    objectSheet.get_Range(objectSheet.Cells[RowIndex,ColumnIndex],objectSheet.Cells[RowIndex,ColumnIndex]).Font.Color = Color;
    //----设置字体大小
    objectSheet.get_Range(objectSheet.Cells[RowIndex,ColumnIndex],objectSheet.Cells[RowIndex,ColumnIndex]).Font.Size  = Size;
      

  5.   

    一定要这样设置:
    //---------设置背景颜色 
    objectSheet.get_Range(objectSheet.Cells[RowIndex,ColumnIndex],objectSheet.Cells[RowIndex,ColumnIndex]).Cells.Interior.Color = System.Drawing.Color.Red.ToArgb();//注意地方
    //---设置字体颜色
    objectSheet.get_Range(objectSheet.Cells[RowIndex,ColumnIndex],objectSheet.Cells[RowIndex,ColumnIndex]).Font.Color = System.Drawing.Color.Yellow.ToArgb();();//注意地方 //----设置字体大小
    objectSheet.get_Range(objectSheet.Cells[RowIndex,ColumnIndex],objectSheet.Cells[RowIndex,ColumnIndex]).Font.Size  = System.Drawing.Font.Size.........;
      

  6.   

    测试通过
    //设置背景颜色 
    //objectSheet.get_Range(objectSheet.Cells[RowIndex,ColumnIndex],objectSheet.Cells[RowIndex,ColumnIndex]).Cells.Interior.Color = System.Drawing.Color.Red.ToArgb();
    //---设置字体颜色
    objectSheet.get_Range(objectSheet.Cells[RowIndex,ColumnIndex],objectSheet.Cells[RowIndex,ColumnIndex]).Font.Color = System.Drawing.Color.Yellow.ToArgb();
    //----设置字体大小
    objectSheet.get_Range(objectSheet.Cells[RowIndex,ColumnIndex],objectSheet.Cells[RowIndex,ColumnIndex]).Font.Size  = 50;