コード例 #1
0
        public IActionResult Word()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument();
            //获取Table所在的数据区域对象
            PageOfficeNetCore.WordWriter.DataRegion dataRegion = doc.OpenDataRegion("PO_regTable");
            //打开table,OpenTable(index)方法中的index代表Word文档中table位置的索引,从1开始
            PageOfficeNetCore.WordWriter.Table table = dataRegion.OpenTable(1);
            //给table中的单元格赋值, OpenCellRC(行, 列)
            table.OpenCellRC(3, 1).Value = "A公司";
            table.OpenCellRC(3, 2).Value = "开发部";
            table.OpenCellRC(3, 3).Value = "李清";
            //插入一空行,InsertRowAfter方法中的参数表示在哪个单元格下面插入一行
            table.InsertRowAfter(table.OpenCellRC(3, 3));

            table.OpenCellRC(4, 1).Value = "B公司";
            table.OpenCellRC(4, 2).Value = "销售部";
            table.OpenCellRC(4, 3).Value = "张三";
            pageofficeCtrl.SetWriter(doc);
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
コード例 #2
0
        public IActionResult Word()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.WordWriter.WordDocument doc    = new PageOfficeNetCore.WordWriter.WordDocument();
            PageOfficeNetCore.WordWriter.Table        table1 = doc.OpenDataRegion("PO_T001").OpenTable(1);
            table1.OpenCellRC(1, 1).Value = "[image]doc/wang.gif[/image]";

            int oldRowCount  = 3; //表格中原有的行数
            int dataRowCount = 5; //要填充数据的行数

            // 扩充表格
            for (int j = 0; j < dataRowCount - oldRowCount; j++)
            {
                table1.InsertRowAfter(table1.OpenCellRC(2, 5));  //在第2行的最后一个单元格下插入新行
            }

            // 填充数据
            int i = 1;

            while (i <= dataRowCount)
            {
                table1.OpenCellRC(i, 2).Value = "AA" + i.ToString();
                table1.OpenCellRC(i, 3).Value = "BB" + i.ToString();
                table1.OpenCellRC(i, 4).Value = "CC" + i.ToString();
                table1.OpenCellRC(i, 5).Value = "DD" + i.ToString();
                i++;
            }
            pageofficeCtrl.SetWriter(doc);
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test_table.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
コード例 #3
0
        public IActionResult Word()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";
            PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument();
            //获取Table所在的数据区域对象
            PageOfficeNetCore.WordWriter.DataRegion dataRegion = doc.OpenDataRegion("PO_regTable");
            //打开table,OpenTable(index)方法中的index代表Word文档中table位置的索引,从1开始
            PageOfficeNetCore.WordWriter.Table table = dataRegion.OpenTable(1);
            //给table中的单元格赋值, OpenCellRC(行, 列)
            table.OpenCellRC(3, 1).Value = "A公司";
            table.OpenCellRC(3, 2).Value = "开发部";
            table.OpenCellRC(3, 3).Value = "李清";
            //插入一空行,InsertRowAfter方法中的参数表示在哪个单元格下面插入一行
            table.InsertRowAfter(table.OpenCellRC(3, 3));

            table.OpenCellRC(4, 1).Value = "B公司";
            table.OpenCellRC(4, 2).Value = "销售部";
            table.OpenCellRC(4, 3).Value = "张三";

            //设置表格行的高度
            table.SetRowsHeight(30.5f);

            //设置表格的边框样式
            PageOfficeNetCore.WordWriter.Border border = table.Border;
            // 设置边框的类型
            border.BorderType = PageOfficeNetCore.WordWriter.WdBorderType.wdFullGrid; //包含内边框
                                                                                      //设置边框的颜色
            border.LineColor = Color.Red;
            //设置边框的线条样式
            border.LineStyle = PageOfficeNetCore.WordWriter.WdLineStyle.wdLineStyleDot;
            //设置边框的粗细
            border.LineWidth = PageOfficeNetCore.WordWriter.WdLineWidth.wdLineWidth150pt;

            //设置表格字体样式
            PageOfficeNetCore.WordWriter.Font font = dataRegion.Font;
            //设置字体的是否加粗
            font.Bold = true;
            //设置字体的颜色
            font.Color = Color.Blue;
            //设置字体是否为斜体
            font.Italic = true;
            //设置字体名称
            font.Name = "宋体";
            //设置字体大小
            font.Size = 15.5f;

            pageofficeCtrl.SetWriter(doc);
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }