public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); PageOfficeNetCore.WordWriter.DataRegion dataReg = doc.OpenDataRegion("PO_deptName"); //为方便用户知道哪些地方可以编辑,所以设置了数据区域的背景色 dataReg.Shading.BackgroundPatternColor = Color.Pink; //dataReg.Editing = true; pageofficeCtrl.SetWriter(doc); // 不要忘记此句代码 // 设置数据区域点击时的响应js函数 pageofficeCtrl.JsFunction_OnWordDataRegionClick = "OnWordDataRegionClick()"; pageofficeCtrl.AddCustomToolButton("保存", "Save", 1); pageofficeCtrl.OfficeToolbars = false; pageofficeCtrl.Caption = "为方便用户知道哪些地方可以编辑,所以设置了数据区域的背景色"; //设置保存页面 pageofficeCtrl.SaveFilePage = "SaveDoc"; //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docSubmitForm, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult template() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "../PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); doc.Template.DefineDataRegion("Name", "[ 担保人姓名 ]"); doc.Template.DefineDataRegion("Address", "[ 担保人地址 ]"); doc.Template.DefineDataRegion("Tel", "[ 担保人电话 ]"); doc.Template.DefineDataRegion("Phone", "[ 担保人手机 ]"); doc.Template.DefineDataRegion("Sex", "[ 担保人性别 ]"); doc.Template.DefineDataRegion("Age", "[ 担保人年龄 ]"); doc.Template.DefineDataTag("{ 甲方公司名称 }"); doc.Template.DefineDataTag("{ 乙方公司名称 }"); doc.Template.DefineDataTag("【 合同日期 】"); doc.Template.DefineDataTag("【 合同编号 】"); pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1); pageofficeCtrl.AddCustomToolButton("定义数据区域", "ShowDefineDataRegions()", 3); pageofficeCtrl.AddCustomToolButton("定义数据标签", "ShowDefineDataTags()", 20); pageofficeCtrl.Theme = PageOfficeNetCore.ThemeType.Office2007; pageofficeCtrl.BorderStyle = PageOfficeNetCore.BorderStyleType.BorderThin; pageofficeCtrl.SetWriter(doc); //设置保存页面 pageofficeCtrl.SaveFilePage = "SaveDoc"; //打开Word文档 pageofficeCtrl.WebOpen("/doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
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()); }
public IActionResult Compose2() { int num = 1;//试题编号 string idlist = Request.Query["ids"]; string[] ids = idlist.Split(',');//将idlist按照","截取后存到ids数组中,然后遍历数组用js插入文件即可 PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; string temp = "PO_begin";//新添加的数据区域名称 PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); for (int i = 0; i < ids.Length; i++) { PageOfficeNetCore.WordWriter.DataRegion dataNum = doc.CreateDataRegion("PO_" + num, PageOfficeNetCore.WordWriter.DataRegionInsertType.After, temp); dataNum.Value = num + ".\t"; PageOfficeNetCore.WordWriter.DataRegion dataReg = doc.CreateDataRegion("PO_begin" + (i + 1), PageOfficeNetCore.WordWriter.DataRegionInsertType.After, "PO_" + num); dataReg.Value = "[word]Openfile?id=" + ids[i] + "[/word]"; num++; temp = "PO_begin" + (i + 1); } pageofficeCtrl.SetWriter(doc); pageofficeCtrl.Caption = "生成试卷"; pageofficeCtrl.CustomToolbar = false; //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docReadOnly, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); //打开数据区域 PageOfficeNetCore.WordWriter.DataRegion dTable = doc.OpenDataRegion("PO_table"); //设置数据区域可编辑性 dTable.Editing = true; //打开数据区域中的表格,OpenTable(index)方法中的index为word文档中表格的下标,从1开始 PageOfficeNetCore.WordWriter.Table table1 = doc.OpenDataRegion("PO_Table").OpenTable(1); // 给表头单元格赋值 table1.OpenCellRC(1, 2).Value = "产品1"; table1.OpenCellRC(1, 3).Value = "产品2"; table1.OpenCellRC(2, 1).Value = "A部门"; table1.OpenCellRC(3, 1).Value = "B部门"; pageofficeCtrl.SetWriter(doc); //添加自定义按钮 pageofficeCtrl.AddCustomToolButton("保存", "Save", 1); pageofficeCtrl.AddCustomToolButton("全屏/还原", "IsFullScreen", 4); //设置保存页面 pageofficeCtrl.SaveDataPage = "SaveData"; //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docSubmitForm, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; // 设置保存文件页面 PageOfficeNetCore.WordWriter.WordDocument wordDoc = new PageOfficeNetCore.WordWriter.WordDocument(); pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1); pageofficeCtrl.CustomToolbar = true; //打开数据区域,openDataRegion方法的参数代表Word文档中的书签名称 PageOfficeNetCore.WordWriter.DataRegion dataRegion1 = wordDoc.OpenDataRegion("PO_test1"); dataRegion1.SubmitAsFile = true; PageOfficeNetCore.WordWriter.DataRegion dataRegion2 = wordDoc.OpenDataRegion("PO_test2"); dataRegion2.SubmitAsFile = true; dataRegion2.Editing = true; PageOfficeNetCore.WordWriter.DataRegion dataRegion3 = wordDoc.OpenDataRegion("PO_test3"); dataRegion3.SubmitAsFile = true; pageofficeCtrl.SetWriter(wordDoc); pageofficeCtrl.SaveDataPage = "SaveData"; //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docSubmitForm, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument wordDoc = new PageOfficeNetCore.WordWriter.WordDocument(); //打开数据区域,OpenDataRegion方法的参数代表Word文档中的书签名称 PageOfficeNetCore.WordWriter.DataRegion dataRegion1 = wordDoc.OpenDataRegion("PO_userName"); //设置DataRegion的可编辑性 dataRegion1.Editing = true; //为DataRegion赋值,此处的值可在页面中打开Word文档后在自己进行修改 dataRegion1.Value = ""; PageOfficeNetCore.WordWriter.DataRegion dataRegion2 = wordDoc.OpenDataRegion("PO_deptName"); dataRegion2.Editing = true; dataRegion2.Value = ""; pageofficeCtrl.SetWriter(wordDoc); pageofficeCtrl.SaveDataPage = "SaveData"; pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1); //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docSubmitForm, "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()); }
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 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()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument wordDoc = new PageOfficeNetCore.WordWriter.WordDocument(); //打开数据区域,OpenDataRegion方法的参数代表Word文档中的书签名称 PageOfficeNetCore.WordWriter.DataRegion dataRegion1 = wordDoc.OpenDataRegion("PO_userName"); //为DataRegion赋值 dataRegion1.Value = "张三"; //设置字体样式 dataRegion1.Font.Color = Color.Blue; dataRegion1.Font.Size = 24f; dataRegion1.Font.Name = "隶书"; dataRegion1.Font.Bold = true; PageOfficeNetCore.WordWriter.DataRegion dataRegion2 = wordDoc.OpenDataRegion("PO_deptName"); dataRegion2.Value = "人事部"; dataRegion2.Font.Color = Color.Red; pageofficeCtrl.SetWriter(wordDoc); //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); PageOfficeNetCore.WordWriter.DataRegion d1 = doc.OpenDataRegion("d1"); d1.Font.Color = Color.Green; //设置数据区域文本字体颜色 d1.Font.Name = "华文彩云"; //设置数据区域文本字体样式 d1.Font.Size = 16; //设置数据区域文本字体大小 d1.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; //设置数据区域文本对齐方式 PageOfficeNetCore.WordWriter.DataRegion d2 = doc.OpenDataRegion("d2"); d2.Font.Color = Color.MediumAquamarine; //设置数据区域文本字体颜色 d2.Font.Name = "黑体"; //设置数据区域文本字体样式 d2.Font.Size = 14; //设置数据区域文本字体大小 d2.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft; //设置数据区域文本对齐方式 PageOfficeNetCore.WordWriter.DataRegion d3 = doc.OpenDataRegion("d3"); d3.Font.Color = Color.Purple; //设置数据区域文本字体颜色 d3.Font.Name = "华文行楷"; //设置数据区域文本字体样式 d3.Font.Size = 12; //设置数据区域文本字体大小 d3.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight; //设置数据区域文本对齐方式 pageofficeCtrl.SetWriter(doc); //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; //定义WordDocument对象 PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); //定义DataTag对象 PageOfficeNetCore.WordWriter.DataTag deptTag = doc.OpenDataTag("{部门名}"); deptTag.Font.Color = Color.Green; //给DataTag对象赋值 deptTag.Value = "技术"; PageOfficeNetCore.WordWriter.DataTag userTag = doc.OpenDataTag("{姓名}"); userTag.Font.Color = Color.Green; userTag.Value = "李四"; PageOfficeNetCore.WordWriter.DataTag dateTag = doc.OpenDataTag("【时间】"); dateTag.Font.Color = Color.Blue; dateTag.Value = DateTime.Now.ToString("yyyy-MM-dd"); pageofficeCtrl.SetWriter(doc); //打开Word文档 pageofficeCtrl.WebOpen("doc/test2.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "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"); //定义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()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); doc.Template.DefineDataTag("{ 甲方 }"); doc.Template.DefineDataTag("{ 乙方 }"); doc.Template.DefineDataTag("{ 担保人 }"); doc.Template.DefineDataTag("【 合同日期 】"); doc.Template.DefineDataTag("【 合同编号 】"); pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1); pageofficeCtrl.AddCustomToolButton("定义数据标签", "ShowDefineDataTags()", 20); pageofficeCtrl.Theme = PageOfficeNetCore.ThemeType.Office2007; pageofficeCtrl.BorderStyle = PageOfficeNetCore.BorderStyleType.BorderThin; pageofficeCtrl.SetWriter(doc); //设置保存页面 pageofficeCtrl.SaveFilePage = "SaveDoc"; //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); PageOfficeNetCore.WordWriter.DataRegion dataReg = doc.OpenDataRegion("PO_table"); PageOfficeNetCore.WordWriter.Table table = dataReg.OpenTable(1); //合并table中的单元格 table.OpenCellRC(1, 1).MergeTo(1, 4); //给合并后的单元格赋值 table.OpenCellRC(1, 1).Value = "销售情况表"; //设置单元格文本样式 table.OpenCellRC(1, 1).Font.Color = Color.Red; table.OpenCellRC(1, 1).Font.Size = 24; table.OpenCellRC(1, 1).Font.Name = "楷体"; table.OpenCellRC(1, 1).ParagraphFormat.Alignment = PageOfficeNetCore.WordWriter.WdParagraphAlignment.wdAlignParagraphCenter; pageofficeCtrl.SetWriter(doc);//不要忘记此句代码 pageofficeCtrl.CustomToolbar = false; //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); doc.Template.DefineDataRegion("Name", "[ 姓名 ]"); doc.Template.DefineDataRegion("Address", "[ 地址 ]"); doc.Template.DefineDataRegion("Tel", "[ 电话 ]"); doc.Template.DefineDataRegion("Phone", "[ 手机 ]"); doc.Template.DefineDataRegion("Sex", "[ 性别 ]"); doc.Template.DefineDataRegion("Age", "[ 年龄 ]"); doc.Template.DefineDataRegion("Email", "[ 邮箱 ]"); doc.Template.DefineDataRegion("QQNo", "[ QQ号 ]"); doc.Template.DefineDataRegion("MSNNo", "[ MSN号 ]"); pageofficeCtrl.AddCustomToolButton("保存", "Save()", 1); pageofficeCtrl.AddCustomToolButton("定义数据区域", "ShowDefineDataRegions()", 3); pageofficeCtrl.Theme = PageOfficeNetCore.ThemeType.Office2007; pageofficeCtrl.BorderStyle = PageOfficeNetCore.BorderStyleType.BorderThin; pageofficeCtrl.SetWriter(doc); //设置保存页面 pageofficeCtrl.SaveFilePage = "SaveDoc"; //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
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()); }
public IActionResult SubmitDataOfDoc() { string docID = Request.Query["ID"]; string sql = "select * from leaveRecord 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"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); PageOfficeNetCore.WordWriter.DataRegion drName = doc.OpenDataRegion("PO_name"); drName.Editing = true; PageOfficeNetCore.WordWriter.DataRegion drDept = doc.OpenDataRegion("PO_dept"); drDept.Shading.BackgroundPatternColor = Color.Silver; //drDept.Editing = true; PageOfficeNetCore.WordWriter.DataRegion drCause = doc.OpenDataRegion("PO_cause"); drCause.Editing = true; PageOfficeNetCore.WordWriter.DataRegion drNum = doc.OpenDataRegion("PO_num"); drNum.Editing = true; PageOfficeNetCore.WordWriter.DataRegion drDate = doc.OpenDataRegion("PO_date"); drDate.Shading.BackgroundPatternColor = Color.Pink; //drDate.Editing = true; PageOfficeNetCore.WordWriter.DataRegion drTip = doc.OpenDataRegion("PO_tip"); drTip.Font.Italic = true; drTip.Value = "提示:带背景色的文字是只能通过选择设置,[]中的文字是可以录入编辑的。"; if (dr.Read()) { doc.OpenDataRegion("PO_name").Value = dr["Name"].ToString(); doc.OpenDataRegion("PO_dept").Value = dr["Dept"].ToString(); doc.OpenDataRegion("PO_cause").Value = dr["Cause"].ToString(); doc.OpenDataRegion("PO_num").Value = dr["Num"].ToString();; doc.OpenDataRegion("PO_date").Value = dr["SubmitTime"].ToString();; } dr.Close(); conn.Close(); // 设置界面样式 pageofficeCtrl.Caption = "用户填写请假条"; pageofficeCtrl.BorderStyle = PageOfficeNetCore.BorderStyleType.BorderThin; // 添加自定义工具条按钮 pageofficeCtrl.AddCustomToolButton("保存", "poSave", 1); pageofficeCtrl.AddCustomToolButton("全屏/还原", "poSetFullScreen", 4); pageofficeCtrl.JsFunction_OnWordDataRegionClick = "OnWordDataRegionClick()"; //获取数据对象 pageofficeCtrl.SetWriter(doc); //设置保存页面 pageofficeCtrl.SaveDataPage = "SaveData?ID=" + docID; //打开Word文档 pageofficeCtrl.WebOpen("/doc/template.doc", PageOfficeNetCore.OpenModeType.docSubmitForm, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
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()); }
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 Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; pageofficeCtrl.AddCustomToolButton("导入文件", "importData()", 5); pageofficeCtrl.AddCustomToolButton("提交数据", "submitData()", 1); PageOfficeNetCore.WordWriter.WordDocument wordDoc = new PageOfficeNetCore.WordWriter.WordDocument(); pageofficeCtrl.SetWriter(wordDoc); //设置保存页面 pageofficeCtrl.SaveDataPage = "SaveDoc"; ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); doc.DisableWindowRightClick = true; //禁止word鼠标右键 //doc.DisableWindowDoubleClick = true;//禁止word鼠标双击 pageofficeCtrl.SetWriter(doc); //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { string user = ""; string userName = Request.Form["userName"]; PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; //***************************卓正PageOffice组件的使用******************************** PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); PageOfficeNetCore.WordWriter.DataRegion dA1 = doc.OpenDataRegion("PO_A_pro1"); PageOfficeNetCore.WordWriter.DataRegion dA2 = doc.OpenDataRegion("PO_A_pro2"); PageOfficeNetCore.WordWriter.DataRegion dB1 = doc.OpenDataRegion("PO_B_pro1"); PageOfficeNetCore.WordWriter.DataRegion dB2 = doc.OpenDataRegion("PO_B_pro2"); //根据登录用户名设置数据区域可编辑性 //A部门经理登录后 if (userName.Equals("zhangsan")) { dA1.Editing = true; dA2.Editing = true; dB1.Editing = false; dB2.Editing = false; user = "******"; } //B部门经理登录后 else { dB1.Editing = true; dB2.Editing = true; dA1.Editing = false; dA2.Editing = false; user = "******"; } pageofficeCtrl.SetWriter(doc); //添加自定义按钮 pageofficeCtrl.AddCustomToolButton("保存", "Save", 1); pageofficeCtrl.AddCustomToolButton("全屏/还原", "IsFullScreen", 4); //设置保存页面 pageofficeCtrl.SaveFilePage = "SaveDoc"; //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docSubmitForm, user); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); ViewBag.user = user; return(View()); }
public IActionResult Word() { string userName = Request.Form["userName"]; PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); //打开数据区域 PageOfficeNetCore.WordWriter.DataRegion d1 = doc.OpenDataRegion("PO_com1"); //给数据区域赋值 d1.Value = "[word]doc/content1.doc[/word]"; //若要将数据区域内容存入文件中,则必须设置属性“SubmitAsFile”值为true d1.SubmitAsFile = true; PageOfficeNetCore.WordWriter.DataRegion d2 = doc.OpenDataRegion("PO_com2"); d2.Value = "[word]doc/content2.doc[/word]"; d2.SubmitAsFile = true; //根据登录用户名设置数据区域可编辑性 //甲客户:zhangsan 登录后登录后 if (userName.Equals("zhangsan")) { d1.Editing = true; d2.Editing = false; } //乙客户:lisi 登录后登录后 else { d2.Editing = true; d1.Editing = false; } pageofficeCtrl.SetWriter(doc); //添加自定义按钮 pageofficeCtrl.AddCustomToolButton("保存", "Save", 1); pageofficeCtrl.AddCustomToolButton("全屏/还原", "IsFullScreen", 4); //设置保存页面 pageofficeCtrl.SaveDataPage = "SaveData?userName="******"doc/test.doc", PageOfficeNetCore.OpenModeType.docSubmitForm, userName); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); ViewBag.userName = userName; return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; PageOfficeNetCore.WordWriter.WordDocument wordDoc = new PageOfficeNetCore.WordWriter.WordDocument(); wordDoc.OpenDataRegion("PO_company").Value = "北京幻想科技有限公司"; wordDoc.OpenDataRegion("PO_logo").Value = "[image]doc/logo.gif[/image]"; wordDoc.OpenDataRegion("PO_dr1").Value = "左边的文本:xxxx"; pageofficeCtrl.SetWriter(wordDoc);// 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。 //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
public IActionResult Word() { PageOfficeNetCore.PageOfficeCtrl pageofficeCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request); pageofficeCtrl.ServerPage = "/PageOffice/POServer"; //设置PageOfficeCtrl 控件标题栏文字 pageofficeCtrl.Caption = "演示:给Word文档添加水印"; //定义一个WordDocument对象 PageOfficeNetCore.WordWriter.WordDocument doc = new PageOfficeNetCore.WordWriter.WordDocument(); //设置水印内容 doc.WaterMark.Text = "PageOffice开发平台"; pageofficeCtrl.SetWriter(doc); //打开Word文档 pageofficeCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }
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_table").OpenTable(1); PageOfficeNetCore.WordWriter.Cell cell = table1.OpenCellRC(2, 1); //删除坐标为(2,1)的单元格所在行 table1.RemoveRowAt(cell); pageofficeCtrl.CustomToolbar = false; pageofficeCtrl.SetWriter(doc); //打开Word文档 pageofficeCtrl.WebOpen("doc/test_table.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom"); ViewBag.POCtrl = pageofficeCtrl.GetHtmlCode("PageOfficeCtrl1"); return(View()); }