韦德国际1946英国 > 计算机网络 > 格式设置

原标题:格式设置

浏览次数:82 时间:2019-05-02

Microsoft.Office.Interop.Excel;

    range壹.Font.Bold = true;//设置石籀文

   worksheet一.PageSetup.HeaderMargin = excel1.CentimetersToPoints(1.2);//页眉边距为1.贰分米(分米转像素)

 

    Worksheet worksheet1 =(Worksheet)workbook1.Worksheets.Add(Type.Missing,workbook1.Worksheets[1], 1, Type.Missing);

  range1.Font.Name = "楷体";//设置字体

二、使用命名空间

    worksheet1.Name = "职业安顿表";

     Workbook workbook1 = excel1.Workbooks.Add(true);

壹、增添引用

    worksheet一.PageSetup.CenterHorizontally = true;//页面水平居中

十、复制Excel表============================

 private void OpenExcel()
        {
            Microsoft.Office.Interop.Excel.Application excel = new ApplicationClass();
            excel.Visible = true;
            excel.DisplayAlerts = false;
            excel.Workbooks.Open(@"D:EXCELIQC查验报表.xlsx");
            ((_Worksheet) excel.Worksheets[1]).Activate();         
            excel.get_Range("F柒",Type.Missing).Value = "测试Excel写入数据";
            excel.get_Range("F7", Type.Missing).Font.Color = Color.Blue;
            excel.ActiveWorkbook.Save();
            excel.Application.Workbooks.Close();
            excel.Application.Quit();
            excel.Quit();
            GC.Collect();
        }

    Microsoft.Office.Interop.Excel.Application excel1 = new Microsoft.Office.Interop.Excel.Application();

    excel1.Visible = true;

三、填充EXCEL单元格方法

      worksheet一.PageSetup.Orientation = XlPageOrientation.xlLandscape;//页面方向为横向

    Workbook workbook1 = excel1.Workbooks.Add(true);

 using Microsoft.Office.Interop.Excel;

    Workbook workbook1 = excel1.Workbooks.Add(true);

    worksheet一.PageSetup.CenterHorizontally = true;//页面水平居中

    worksheet一.Columns.ColumnWidth = 20;//全局行宽

    Microsoft.Office.Interop.Excel.Application excel1 = new Microsoft.Office.Interop.Excel.Application();

    range一.Font.Color = System.Drawing.ColorTranslator.To奥莱(Color.Blue);//设置字体颜色

    Microsoft.Office.Interop.Excel.Application excel1 = new Microsoft.Office.Interop.Excel.Application();

鉴于实在供给必要ASP.net中程导弹出excel并调控EXCEL格式,以下是促成代码

    range壹.Font.Size = 1八;//设置字体大小

    Worksheet worksheet2 =(Worksheet)worksheet1.Next;

    Range range1 = (Range) worksheet1.Cells[2, 1];

    Worksheet worksheet1 = (Worksheet)workbook1.Worksheets["sheet1"或1];

    excel1.Visible = true;

二、新建Excel对象============================

加上引用:Microsoft   Excel   1一.0   Object   Library ;

    Microsoft.Office.Interop.Excel.Application excel1 = new Microsoft.Office.Interop.Excel.Application();

  Microsoft.Office.Interop.Excel.Application excel1 = new Microsoft.Office.Interop.Excel.Application();

    Range range1 = (Range)worksheet1.Cells[2, 2];

    worksheet1.Activate();//激活sheet1表

5、设置或修改Excel表单元格内容========================

    worksheet1.Columns.RowHeight = 20;//全局列高

10一、页面设置============================

    range一.Columns.ColumnWidth = 40;//单元格行宽

    Worksheet worksheet1 = (Worksheet)workbook1.Worksheets["sheet1"];

    worksheet①.PageSetup.PrintTitleRows = "$一:$3";//顶端标题行

    Worksheet worksheet1 =(Worksheet)workbook1.Worksheets.Add(Type.Missing,workbook1.Worksheets[1], 1, Type.Missing);

    Worksheet worksheet1 = (Worksheet)workbook1.Worksheets["sheet1"];

    worksheet1.PageSetup.CenterVertically = false;//页面不垂直居中

             //合并单元格
            xSt.get_Range(excel.Cells[3, 3], excel.Cells[4, 4]).Merge(true);//

    range1.Borders.get_Item(XlBordersIndex.xlDiagonalUp).LineStyle = XlLineStyle.xlContinuous;//反斜杠

    Microsoft.Office.Interop.Excel.Application excel1 = new Microsoft.Office.Interop.Excel.Application();

    excel1.Visible = true;

    range1.Borders.get_Item(XlBordersIndex.xlEdgeTop).LineStyle = XlLineStyle.xlContinuous;

    range1.Borders.get_Item(XlBordersIndex.xlDiagonalDown).LineStyle = XlLineStyle.xlContinuous;//斜杠

  //标题栏固定即为冻结窗口,一下代码达成
xSt.get_Range("B2", "B2").Select();
            excel.ActiveWindow.FreezePanes = true;

5、设置或修改Excel表单元格内容========================

            xBk = excel.Workbooks.Add(true);

    //也可用后边的代码代替上边四项range一.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic,null);

    range1.Borders.Color = System.Drawing.ColorTranslator.ToOle(Color.Red);

  worksheet壹.PageSetup.PaperSize = Xl帕佩rSize.xlPaperA三;//纸张大小

    Workbook workbook1 = excel1.Workbooks.Add(true);

    worksheet1.Cells[1, 1] = "姓名";

     Workbook workbook1 = excel1.Workbooks.Add(true);

    range1.Value2 = "123rn456";

    excel1.Visible = true;

    range1.Borders.get_Item(XlBordersIndex.xlEdgeRight).LineStyle = XlLineStyle.xlContinuous;

    range1.Borders.get_Item(XlBordersIndex.xlDiagonalDown).LineStyle = XlLineStyle.xlContinuous;//斜杠

    range1.Borders.get_Item(XlBordersIndex.xlEdgeRight).LineStyle = XlLineStyle.xlContinuous;

一、打开Excel文件============================

    worksheet1.PageSetup.CenterFooter = "第&P页,共&N页";//中间页脚内容

    Worksheet worksheet1 = (Worksheet)workbook1.Worksheets["sheet1"];

陆、设置Excel表行宽和列高===========================

    Worksheet worksheet1 = (Worksheet)workbook1.Worksheets["sheet1"];

    excel1.Visible = true;

    excel一.Application.DisplayAlerts = false;//使联合操作不提示警示音讯

      worksheet一.PageSetup.Orientation = XlPageOrientation.xlLandscape;//页面方向为横向

    excel1.Visible = true;

三、新建Excel表============================

            xSt.get_Range(excel.Cells[7, 7], excel.Cells[8, 8]).Interior.ColorIndex = 20;//设置背景观为浅灰色,共计有5七种

    Range range1 = (Range)worksheet1.Cells[2, 2];

    Workbook workbook1 = excel1.Workbooks.Add(XlWBATemplate.xlWBATWorksheet或true);

    worksheet一.PageSetup.PrintTitleRows = "$一:$3";//顶端标题行

    Worksheet worksheet1 = (Worksheet)workbook1.Worksheets["sheet1"];

  Microsoft.Office.Interop.Excel.Application excel1 = new Microsoft.Office.Interop.Excel.Application();

    Range range1 = worksheet1.get_Range("A二", "E八");//选取操作块

    excel1.Visible = true;

    Workbook workbook1 = excel1.Workbooks.Open(@"E:/aaa.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

    Workbook workbook1 = excel1.Workbooks.Add(true);

    range1.Borders.get_Item(XlBordersIndex.xlEdgeRight).LineStyle = XlLineStyle.xlContinuous;

    worksheet一.Columns.ColumnWidth = 20;//全局行宽

    worksheet一.PageSetup.CenterVertically = false;//页面不垂直居中

    Microsoft.Office.Interop.Excel.Application excel1 = new Microsoft.Office.Interop.Excel.Application();

本文由韦德国际1946英国发布于计算机网络,转载请注明出处:格式设置

关键词: Excel 操作

上一篇:韦德国际1946英国:二叉树中度为1的结点,非递归

下一篇:没有了