【问题标题】:How to make font size bold in excel如何在excel中使字体大小变粗
【发布时间】:2020-07-10 06:37:57
【问题描述】:

现在我正在开发一个 c# 桌面应用程序,并在此应用程序中完成交易后在 excel 中完成交易导出,但我想将 excel 字体大小设置为粗体我不知道该怎么做,请在这种情况下帮助我。

Thanks.

here is my code

           //creating Excel Application  
            Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
             //creating new WorkBook within Excel application  
            Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
             //creating new Excelsheet in workbook  
            Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
             //see the excel sheet behind the program  
            app.Visible = true;
             //get the reference of first sheet. By default its name is Sheet1.  
             //store its reference to worksheet  
            worksheet = workbook.Sheets["Sheet1"];
            worksheet = workbook.ActiveSheet;
             //changing the name of active sheet  
            worksheet.Name = "Exported from gridview";
             //storing header part in Excel  
            //
            worksheet.Cells[1, 1] = "Customer Name";
            worksheet.Cells[1, 2] = "S/D/W";
            worksheet.Cells[1, 3] = "NIC";
            worksheet.Cells[1, 4] = "Postal Address";
            worksheet.Cells[1, 5] = "Flat No";
            worksheet.Cells[1, 6] = "Type";
            worksheet.Cells[3, 1] = "Floor";
            worksheet.Cells[3, 2] = "Block";
            worksheet.Cells[3, 3] = "Size";
            worksheet.Cells[3, 5] = "File No";
            worksheet.Cells[3, 6] = "Nominee";
            worksheet.Cells[5, 1] = "Relation";
            worksheet.Cells[5, 2] = "nominee_NIC";
            worksheet.Cells[5, 3] = "Contact_NIC";
            worksheet.Cells[5, 4] = "Status";
            worksheet.Cells[5, 5] = "Booking Station";
            worksheet.Cells[5, 6] = "Booked By";
            worksheet.Cells[7, 1] = "Cost";
            worksheet.Cells[7, 2] = "Discount";
            worksheet.Cells[7, 3] = "Total";  
            workbook.SaveAs("D:\\output.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

【问题讨论】:

标签: c# excel fonts export bold


【解决方案1】:

worksheet.Cells[1, 1].Font.Bold = true; 应该可以完成这项工作

【讨论】:

    猜你喜欢
    • 2011-10-21
    • 2021-06-06
    • 2011-12-05
    • 2015-10-17
    • 2011-10-18
    • 1970-01-01
    • 2015-01-30
    • 2012-07-12
    • 1970-01-01
    相关资源
    最近更新 更多