本帖最后由 kj86345580 于 2014-04-15 17:25:26 编辑

解决方案 »

  1.   

    在Excel中录制一个宏,然后照着样子在你的程序中写。
      

  2.   

    貌似用这个Range  可以实现
      

  3.   

    就是range属性众多,不知道具体该怎么用
      

  4.   

    我录了一个宏,宏代码如下:
    Range("A2:L2").Select
        Application.WindowState = xlMinimized
        Application.WindowState = xlNormal
        Range("A2:L2").Select
        ActiveCell.FormulaR1C1 = _
            "华洪珠宝首饰有限公司客户产品出货单" & Chr(10) & "送货单位:润邦迈李饰品        NO:55094     2013.12.10"
        With ActiveCell.Characters(Start:=1, Length:=0).Font
            .Name = "宋体"
            .FontStyle = "加粗"
            .Size = 22
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .Color = -16777216
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        With ActiveCell.Characters(Start:=1, Length:=17).Font
            .Name = "宋体"
            .FontStyle = "加粗"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .Color = -16777216
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        With ActiveCell.Characters(Start:=18, Length:=6).Font
            .Name = "宋体"
            .FontStyle = "加粗"
            .Size = 22
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .Color = -16777216
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        With ActiveCell.Characters(Start:=24, Length:=7).Font
            .Name = "宋体"
            .FontStyle = "加粗"
            .Size = 22
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .Color = -16776961
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        With ActiveCell.Characters(Start:=31, Length:=30).Font
            .Name = "宋体"
            .FontStyle = "加粗"
            .Size = 22
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .Color = -16777216
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        Range("G6").Select
    End Sub
    但是完全不知道怎么照样写,求指导一下,就我说的效果,帮我写一个例子!万分感谢!!
      

  5.   

    就是range属性众多,不知道具体该怎么用额,这个你google下就知道了啊。
    自己看
      

  6.   

    就是range属性众多,不知道具体该怎么用额,这个你google下就知道了啊。
    自己看
    这个我知道,这种方法是把单元格作为一个整体来进行操作的,比如加粗会把整个单元格的所有文字加粗,但我现在要的是把单元格内指定的某个字加粗而已···
      

  7.   

    录制完宏,还懒得研究人家excel产生的代码,这就没救了。
      

  8.   

    我是web的,用npoi,先创建excel,再创建格式 HSSFWorkbook workbook = new HSSFWorkbook();
                HSSFSheet sheet = workbook.CreateSheet(strFileNamet);
              try
                {
                    #region 创建标题行及其相关的样式
                    HSSFRow titleRow = sheet.CreateRow(0);
                    titleRow.HeightInPoints = 30; //行高
                    titleRow.CreateCell(0).SetCellValue(strHeaderText);//标题名
                    HSSFCellStyle titleCellStyle = workbook.CreateCellStyle(); //标题单元格样式
                    //标题字体样式
                    HSSFFont titleFont = workbook.CreateFont();
                    titleFont.FontName = "宋体";
                    titleFont.FontHeightInPoints = 22;
                    titleFont.Boldweight = 700;
                    //设置标题行的样式
                    titleCellStyle.SetFont(titleFont);
                    titleCellStyle.Alignment = CellHorizontalAlignment.CENTER;
                    titleCellStyle.VerticalAlignment = CellVerticalAlignment.CENTER;
                    titleRow.GetCell(0).CellStyle = titleCellStyle;
                    sheet.AddMergedRegion(new Region(0, 0, 0, 10));//合并
                    #endregion