public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            //定义Workbook对象
            PageOfficeNetCore.ExcelWriter.Workbook workBook = new PageOfficeNetCore.ExcelWriter.Workbook();
            //定义Sheet对象,"Sheet1"是打开的Excel表单的名称
            PageOfficeNetCore.ExcelWriter.Sheet sheet = workBook.OpenSheet("Sheet1");
            //定义Table对象
            PageOfficeNetCore.ExcelWriter.Table table = sheet.OpenTable("B4:F13");
            for (int i = 0; i < 50; i++)
            {
                table.DataFields[0].Value = "产品 " + i.ToString();
                table.DataFields[1].Value = "100";
                table.DataFields[2].Value = (100 + i).ToString();
                table.NextRow();
            }
            table.Close();

            pageofficeCtrl.SetWriter(workBook);// 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。
            pageofficeCtrl.Caption = "使用OpenTable给Excel赋值";

            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
예제 #2
0
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.ExcelWriter.Workbook workBook = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    sheet    = workBook.OpenSheet("Sheet1");
            //定义table对象,设置table对象的设置范围
            PageOfficeNetCore.ExcelWriter.Table table = sheet.OpenTable("B4:D8");
            //设置table对象的提交名称,以便保存页面获取提交的数据
            table.SubmitName = "Info";
            pageofficeCtrl.SetWriter(workBook);

            // 设置响应单元格点击事件的js function
            pageofficeCtrl.JsFunction_OnExcelCellClick = "OnCellClick()";

            pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1);

            //设置保存页面
            pageofficeCtrl.SaveDataPage = "SaveData";
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsSubmitForm, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            //定义Workbook对象
            PageOfficeNetCore.ExcelWriter.Workbook workBook = new PageOfficeNetCore.ExcelWriter.Workbook();
            //定义Sheet对象,"Sheet1"是打开的Excel表单的名称
            PageOfficeNetCore.ExcelWriter.Sheet sheet = workBook.OpenSheet("Sheet1");
            //定义Cell对象,给单元格赋值
            PageOfficeNetCore.ExcelWriter.Cell cellB4 = sheet.OpenCell("B4");
            cellB4.Value = "1月";
            //或者直接给Cell赋值
            sheet.OpenCell("C4").Value = "300";
            sheet.OpenCell("D4").Value = "270";
            sheet.OpenCell("E4").Value = "270";
            sheet.OpenCell("F4").Value = string.Format("{0:P}", 270.0 / 300);

            pageofficeCtrl.SetWriter(workBook);// 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。

            pageofficeCtrl.Caption = "简单的给Excel赋值";
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
예제 #4
0
        public IActionResult ExcelFill()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.ExcelWriter.Workbook wk    = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    sheet = wk.OpenSheet("Sheet1");
            PageOfficeNetCore.ExcelWriter.Table    table = sheet.OpenTableByDefinedName("report", 10, 5, false);
            table.DataFields[0].Value = "轮胎";
            table.DataFields[1].Value = "100";
            table.DataFields[2].Value = "120";
            table.DataFields[3].Value = "500";
            table.DataFields[4].Value = "120%";
            table.NextRow();
            table.Close();
            pageofficeCtrl.SetWriter(wk);// 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。

            pageofficeCtrl.Caption      = "给Excel文档中定义名称的单元格赋值";
            pageofficeCtrl.SaveDataPage = "SaveData";
            pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1);
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsSubmitForm, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
예제 #5
0
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.ExcelWriter.Workbook workBook = new PageOfficeNetCore.ExcelWriter.Workbook();
            workBook.DisableSheetRightClick = true;//禁止当前工作表的鼠标右键                                                   //workBook.DisableSheetDoubleClick = true;//禁止当前工作表的鼠标双击
            pageofficeCtrl.SetWriter(workBook);

            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
        public IActionResult Excel()
        {
            string userName = Request.Form["userName"];

            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            //***************************卓正PageOffice组件的使用********************************
            PageOfficeNetCore.ExcelWriter.Workbook wb     = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    sheet  = wb.OpenSheet("Sheet1");
            PageOfficeNetCore.ExcelWriter.Table    tableA = sheet.OpenTable("C4:D6");
            PageOfficeNetCore.ExcelWriter.Table    tableB = sheet.OpenTable("C7:D9");

            tableA.SubmitName = "tableA";
            tableB.SubmitName = "tableB";

            //根据登录用户名设置数据区域可编辑性
            //A部门经理登录后
            String strInfo = "";

            if (userName.Equals("zhangsan"))
            {
                strInfo         = "A部门经理,所以只能编辑A部门的产品数据";
                tableA.ReadOnly = false;
                tableB.ReadOnly = true;
            }
            //B部门经理登录后
            else
            {
                strInfo         = "B部门经理,所以只能编辑B部门的产品数据";
                tableA.ReadOnly = true;
                tableB.ReadOnly = false;
            }

            pageofficeCtrl.SetWriter(wb);

            pageofficeCtrl.AddCustomToolButton("保存", "Save", 1);

            //设置保存页面
            pageofficeCtrl.SaveFilePage = "SaveDoc";

            pageofficeCtrl.SaveDataPage = "SaveData";//保存数据

            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsSubmitForm, "tom");
            ViewBag.POCtrl  = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            ViewBag.strInfo = strInfo;
            return(View());
        }
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.ExcelWriter.Workbook worbBook = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    Sheetl   = worbBook.OpenSheet("Sheet1");
            PageOfficeNetCore.ExcelWriter.Cell     cell1    = Sheetl.OpenCell("A1");
            cell1.Value = "[image]image/logo.jpg[/image]";
            pageofficeCtrl.SetWriter(worbBook);
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.ExcelWriter.Workbook wb     = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    sheet1 = wb.OpenSheet("Sheet1");
            //设置当工作表只读时,是否允许用户手动调整行列。
            sheet1.AllowAdjustRC = true;
            pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1);

            pageofficeCtrl.SetWriter(wb);
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsReadOnly, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
예제 #9
0
        public IActionResult ExcelFill4()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";
            PageOfficeNetCore.ExcelWriter.Workbook wk    = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    sheet = wk.OpenSheet("Sheet1");
            PageOfficeNetCore.ExcelWriter.Table    table = sheet.OpenTable("B4:F11");
            int rowCount = 12;//假设将要自动填充数据的实际记录条数为12

            for (int i = 1; i <= rowCount; i++)
            {
                table.DataFields[0].Value = i + "月";
                table.DataFields[1].Value = "100";
                table.DataFields[2].Value = "120";
                table.DataFields[3].Value = "500";
                table.DataFields[4].Value = "120%";
                table.NextRow();
            }
            table.Close();

            //定义另一个table
            PageOfficeNetCore.ExcelWriter.Table table2 = sheet.OpenTable("B13:F16");
            int rowCount2 = 4;//假设将要自动填充数据的实际记录条数为12

            for (int i = 1; i <= rowCount2; i++)
            {
                table2.DataFields[0].Value = i + "季度";
                table2.DataFields[1].Value = "300";
                table2.DataFields[2].Value = "300";
                table2.DataFields[3].Value = "300";
                table2.DataFields[4].Value = "100%";
                table2.NextRow();
            }

            table2.Close();
            pageofficeCtrl.SetWriter(wk);// 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。

            //隐藏菜单栏
            pageofficeCtrl.Menubar      = false;
            pageofficeCtrl.Caption      = "给Excel文档中定义名称的单元格赋值";
            pageofficeCtrl.SaveDataPage = "SaveData";
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test4.xls", PageOfficeNetCore.OpenModeType.xlsSubmitForm, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.ExcelWriter.Workbook wb    = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    sheet = wb.OpenSheet("Sheet1");
            // 设置背景
            PageOfficeNetCore.ExcelWriter.Table backGroundTable = sheet.OpenTable("A1:P200");
            //设置表格边框样式
            backGroundTable.Border.LineColor = Color.White;

            // 设置单元格边框样式
            PageOfficeNetCore.ExcelWriter.Border C4Border = sheet.OpenTable("C4:C4").Border;
            C4Border.Weight     = PageOfficeNetCore.ExcelWriter.XlBorderWeight.xlThick;
            C4Border.LineColor  = Color.Yellow;
            C4Border.BorderType = PageOfficeNetCore.ExcelWriter.XlBorderType.xlAllEdges;

            // 设置单元格边框样式
            PageOfficeNetCore.ExcelWriter.Border B6Border = sheet.OpenTable("B6:B6").Border;
            B6Border.Weight     = PageOfficeNetCore.ExcelWriter.XlBorderWeight.xlHairline;
            B6Border.LineColor  = Color.Purple;
            B6Border.LineStyle  = PageOfficeNetCore.ExcelWriter.XlBorderLineStyle.xlSlantDashDot;
            B6Border.BorderType = PageOfficeNetCore.ExcelWriter.XlBorderType.xlAllEdges;

            //设置表格边框样式
            PageOfficeNetCore.ExcelWriter.Table titleTable = sheet.OpenTable("B4:F5");
            titleTable.Border.Weight     = PageOfficeNetCore.ExcelWriter.XlBorderWeight.xlThick;
            titleTable.Border.LineColor  = Color.FromArgb(0, 128, 128);
            titleTable.Border.BorderType = PageOfficeNetCore.ExcelWriter.XlBorderType.xlAllEdges;

            //设置表格边框样式
            PageOfficeNetCore.ExcelWriter.Table bodyTable2 = sheet.OpenTable("B6:F15");
            bodyTable2.Border.Weight     = PageOfficeNetCore.ExcelWriter.XlBorderWeight.xlThick;
            bodyTable2.Border.LineColor  = Color.FromArgb(0, 128, 128);
            bodyTable2.Border.BorderType = PageOfficeNetCore.ExcelWriter.XlBorderType.xlAllEdges;

            pageofficeCtrl.SetWriter(wb);// 不要忘记此句代码

            pageofficeCtrl.AddCustomToolButton("全屏/还原", "IsFullScreen", 4);
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
예제 #11
0
        public IActionResult excel2()
        {
            string           DocID = Request.Query["ID"];
            string           sql   = "select * from excel where ID = " + DocID + ";";
            SqliteConnection conn  = new SqliteConnection(connString);

            conn.Open();
            SqliteCommand cmd = new SqliteCommand(sql, conn);

            cmd.ExecuteNonQuery();
            cmd.CommandText = sql;

            SqliteDataReader dr = cmd.ExecuteReader();

            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "../PageOffice/POServer";
            string docFile    = "";
            string docSubject = "";

            while (dr.Read())
            {
                docFile    = dr["FileName"].ToString();
                docSubject = dr["Subject"].ToString();
            }
            dr.Close();
            conn.Close();
            //设置保存页面
            pageofficeCtrl.SaveFilePage = "/Edit/SaveDoc";
            PageOfficeNetCore.ExcelWriter.Workbook wb = new PageOfficeNetCore.ExcelWriter.Workbook();
            wb.DisableSheetDoubleClick = true;
            wb.DisableSheetRightClick  = true;
            pageofficeCtrl.SetWriter(wb);
            pageofficeCtrl.AddCustomToolButton("另存为...", "saveAs", 1);
            pageofficeCtrl.AddCustomToolButton("打印设置", "setPrint", 0);
            pageofficeCtrl.AddCustomToolButton("全屏/还原", "setFullScreen", 4);
            pageofficeCtrl.Caption = "Excel文件:" + docSubject;

            //打开Word文档
            pageofficeCtrl.WebOpen("/doc/" + docFile, PageOfficeNetCore.OpenModeType.xlsReadOnly, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            ViewBag.time   = DateTime.Now.ToString("yyyy年MM月dd日 dddd");
            return(View());
        }
예제 #12
0
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            //定义Workbook对象
            PageOfficeNetCore.ExcelWriter.Workbook workBook = new PageOfficeNetCore.ExcelWriter.Workbook();
            //定义Sheet对象,"Sheet1"是打开的Excel表单的名称
            PageOfficeNetCore.ExcelWriter.Sheet sheet = workBook.OpenSheet("Sheet1");
            pageofficeCtrl.SetWriter(workBook);

            //添加自定义按钮
            pageofficeCtrl.AddCustomToolButton("导入文件", "importData()", 5);
            pageofficeCtrl.AddCustomToolButton("提交数据", "submitData()", 1);

            //设置保存页面
            pageofficeCtrl.SaveDataPage = "SaveDoc";
            //打开Word文档
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
예제 #13
0
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.ExcelWriter.Workbook wb    = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    sheet = wb.OpenSheet("Sheet1");
            //合并单元格
            sheet.OpenTable("B2:F2").Merge();
            PageOfficeNetCore.ExcelWriter.Cell cB2 = sheet.OpenCell("B2");
            cB2.Value = "北京某公司产品销售情况";
            //设置水平对齐方式
            cB2.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;
            cB2.ForeColor           = Color.Red;
            cB2.Font.Size           = 16;

            sheet.OpenTable("B4:B6").Merge();//合并单元格
            PageOfficeNetCore.ExcelWriter.Cell cB4 = sheet.OpenCell("B4");
            cB4.Value = "A产品";
            //设置水平对齐方式
            cB4.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;
            //设置垂直对齐方式
            cB4.VerticalAlignment = PageOfficeNetCore.ExcelWriter.XlVAlign.xlVAlignCenter;

            sheet.OpenTable("B7:B9").Merge();//合并单元格
            PageOfficeNetCore.ExcelWriter.Cell cB7 = sheet.OpenCell("B7");
            cB7.Value = "B产品";
            cB7.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;
            cB7.VerticalAlignment   = PageOfficeNetCore.ExcelWriter.XlVAlign.xlVAlignCenter;

            pageofficeCtrl.SetWriter(wb);

            pageofficeCtrl.AddCustomToolButton("全屏/还原", "IsFullScreen", 4);
            pageofficeCtrl.Caption = "演示:使用程序合并指定的单元格并设置格式和赋值";

            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
예제 #14
0
        public IActionResult ExcelFill2()
        {
            string tempFileName = Request.Query["temp"];

            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.ExcelWriter.Workbook wk    = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    sheet = wk.OpenSheet("Sheet1");
            PageOfficeNetCore.ExcelWriter.Table    table = sheet.OpenTableByDefinedName("report", 10, 5, false);
            table.DataFields[0].Value = "轮胎";
            table.DataFields[1].Value = "100";
            table.DataFields[2].Value = "120";
            table.DataFields[3].Value = "500";
            table.DataFields[4].Value = "120%";
            table.NextRow();
            table.Close();
            // 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。
            //定义单元格对象,参数“year”就是Excel模板中定义的单元格的名称
            PageOfficeNetCore.ExcelWriter.Cell cellYear = sheet.OpenCellByDefinedName("year");
            // 给单元格赋值
            cellYear.Value = "2015年";

            PageOfficeNetCore.ExcelWriter.Cell cellName = sheet.OpenCellByDefinedName("name");
            cellName.Value = "张三";

            pageofficeCtrl.SetWriter(wk);
            //隐藏菜单栏
            pageofficeCtrl.Menubar = false;

            pageofficeCtrl.Caption      = "给Excel文档中定义名称的单元格赋值";
            pageofficeCtrl.SaveDataPage = "SaveData";
            pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1);

            //打开Word文档
            pageofficeCtrl.WebOpen("doc/" + tempFileName, PageOfficeNetCore.OpenModeType.xlsSubmitForm, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
예제 #15
0
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";
            pageofficeCtrl.Caption    = "简单的给Excel赋值";
            //定义Workbook对象
            PageOfficeNetCore.ExcelWriter.Workbook workBook = new PageOfficeNetCore.ExcelWriter.Workbook();
            //定义Sheet对象,"Sheet1"是打开的Excel表单的名称
            PageOfficeNetCore.ExcelWriter.Sheet sheet = workBook.OpenSheet("Sheet1");
            //定义Cell对象
            PageOfficeNetCore.ExcelWriter.Cell cellB4 = sheet.OpenCell("B4");
            //给单元格赋值
            cellB4.Value = "1月";
            //设置字体颜色
            cellB4.ForeColor = Color.Red;

            PageOfficeNetCore.ExcelWriter.Cell cellC4 = sheet.OpenCell("C4");
            cellC4.Value     = "300";
            cellC4.ForeColor = Color.Blue;

            PageOfficeNetCore.ExcelWriter.Cell cellD4 = sheet.OpenCell("D4");
            cellD4.Value     = "270";
            cellD4.ForeColor = Color.Orange;

            PageOfficeNetCore.ExcelWriter.Cell cellE4 = sheet.OpenCell("E4");
            cellE4.Value     = "270";
            cellE4.ForeColor = Color.Green;

            PageOfficeNetCore.ExcelWriter.Cell cellF4 = sheet.OpenCell("F4");
            cellF4.Value     = string.Format("{0:P}", 270.0 / 300);
            cellF4.ForeColor = Color.Gray;

            pageofficeCtrl.SetWriter(workBook);
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            //定义Workbook对象
            PageOfficeNetCore.ExcelWriter.Workbook workBook = new PageOfficeNetCore.ExcelWriter.Workbook();
            //定义Sheet对象,"Sheet1"是打开的Excel表单的名称
            PageOfficeNetCore.ExcelWriter.Sheet sheet = workBook.OpenSheet("Sheet1");
            sheet.OpenCellByDefinedName("testA1").Value = "Tom";
            sheet.OpenCellByDefinedName("testB1").Value = "John";
            // 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。
            pageofficeCtrl.SetWriter(workBook);

            pageofficeCtrl.Caption = "给Excel文档中定义名称的单元格赋值";
            pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1);
            //设置保存页面
            pageofficeCtrl.SaveDataPage = "SaveData";
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsSubmitForm, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }
        public IActionResult Excel()
        {
            PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            pageofficeCtrl.ServerPage = "/PageOffice/POServer";

            PageOfficeNetCore.ExcelWriter.Workbook wb    = new PageOfficeNetCore.ExcelWriter.Workbook();
            PageOfficeNetCore.ExcelWriter.Sheet    sheet = wb.OpenSheet("Sheet1");

            PageOfficeNetCore.ExcelWriter.Cell cC3 = sheet.OpenCell("C3");
            //设置单元格背景样式
            cC3.BackColor           = Color.AntiqueWhite;
            cC3.Value               = "一月";
            cC3.ForeColor           = Color.Green;
            cC3.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;

            PageOfficeNetCore.ExcelWriter.Cell cD3 = sheet.OpenCell("D3");
            //设置单元格背景样式
            cD3.BackColor           = Color.AntiqueWhite;
            cD3.Value               = "二月";
            cD3.ForeColor           = Color.Green;
            cD3.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;

            PageOfficeNetCore.ExcelWriter.Cell cE3 = sheet.OpenCell("E3");
            //设置单元格背景样式
            cE3.BackColor           = Color.AntiqueWhite;
            cE3.Value               = "三月";
            cE3.ForeColor           = Color.Green;
            cE3.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;

            PageOfficeNetCore.ExcelWriter.Cell cB4 = sheet.OpenCell("B4");
            //设置单元格背景样式
            cB4.BackColor           = Color.SkyBlue;
            cB4.Value               = "住房";
            cB4.ForeColor           = Color.Wheat;
            cB4.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;

            PageOfficeNetCore.ExcelWriter.Cell cB5 = sheet.OpenCell("B5");
            //设置单元格背景样式
            cB5.BackColor           = Color.Teal;
            cB5.Value               = "三餐";
            cB5.ForeColor           = Color.Wheat;
            cB5.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;

            PageOfficeNetCore.ExcelWriter.Cell cB6 = sheet.OpenCell("B6");
            //设置单元格背景样式
            cB6.BackColor           = Color.MediumPurple;
            cB6.Value               = "车费";
            cB6.ForeColor           = Color.Wheat;
            cB6.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;

            PageOfficeNetCore.ExcelWriter.Cell cB7 = sheet.OpenCell("B7");
            //设置单元格背景样式
            cB7.BackColor           = Color.SteelBlue;
            cB7.Value               = "通讯";
            cB7.ForeColor           = Color.Wheat;
            cB7.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;

            //绘制表格线
            PageOfficeNetCore.ExcelWriter.Table titleTable = sheet.OpenTable("B3:E10");
            titleTable.Border.Weight     = PageOfficeNetCore.ExcelWriter.XlBorderWeight.xlThick;
            titleTable.Border.LineColor  = Color.FromArgb(0, 128, 128);
            titleTable.Border.BorderType = PageOfficeNetCore.ExcelWriter.XlBorderType.xlAllEdges;

            //合并单元格后赋值
            sheet.OpenTable("B1:E2").Merge();
            sheet.OpenTable("B1:E2").RowHeight = 30;//设置行高
            PageOfficeNetCore.ExcelWriter.Cell B1 = sheet.OpenCell("B1");
            //设置单元格文本样式
            B1.HorizontalAlignment = PageOfficeNetCore.ExcelWriter.XlHAlign.xlHAlignCenter;
            B1.VerticalAlignment   = PageOfficeNetCore.ExcelWriter.XlVAlign.xlVAlignCenter;
            B1.ForeColor           = Color.FromArgb(0, 128, 128);
            B1.Value     = "出差开支预算";
            B1.Font.Bold = true;
            B1.Font.Size = 25;

            pageofficeCtrl.SetWriter(wb); // 不要忘记此句代码
            //打开Word文档
            pageofficeCtrl.WebOpen("doc/test.xls", PageOfficeNetCore.OpenModeType.xlsNormalEdit, "tom");
            ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1");
            return(View());
        }