Ejemplo n.º 1
0
    protected void PageOfficeCtrl1_Load(object sender, EventArgs e)
    {
        // 设置PageOffice组件服务页面
        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx";
        // 设置保存文件页面
        PageOffice.WordWriter.WordDocument wordDoc = new PageOffice.WordWriter.WordDocument();
        PageOfficeCtrl1.AddCustomToolButton("保存", "Save()", 1);
        PageOfficeCtrl1.CustomToolbar = true;
        //打开数据区域,openDataRegion方法的参数代表Word文档中的书签名称
        PageOffice.WordWriter.DataRegion dataRegion1 = wordDoc.OpenDataRegion("PO_test1");
        dataRegion1.SubmitAsFile = true;
        PageOffice.WordWriter.DataRegion dataRegion2 = wordDoc.OpenDataRegion("PO_test2");
        dataRegion2.SubmitAsFile = true;
        dataRegion2.Editing      = true;
        PageOffice.WordWriter.DataRegion dataRegion3 = wordDoc.OpenDataRegion("PO_test3");
        dataRegion3.SubmitAsFile = true;


        PageOfficeCtrl1.SetWriter(wordDoc);

        PageOfficeCtrl1.SaveDataPage = "SaveData.aspx";

        // 打开文档
        PageOfficeCtrl1.WebOpen("doc/test.doc", PageOffice.OpenModeType.docSubmitForm, "Tom");
    }
 /// <summary>
 /// Aspx写法载入office模板
 /// </summary>
 /// <returns></returns>
 public ActionResult OfficeEditAspxIndex()
 {
     #region 火情报告模板自动填充内容
     PageOffice.WordWriter.WordDocument doc = new PageOffice.WordWriter.WordDocument();
     doc.OpenDataRegion("PO_Year").Value  = DateTime.Now.Year.ToString();
     doc.OpenDataRegion("PO_Month").Value = DateTime.Now.Month.ToString();
     doc.OpenDataRegion("PO_Day").Value   = DateTime.Now.Day.ToString();
     doc.OpenDataRegion("PO_Hour").Value  = DateTime.Now.Hour.ToString();
     #endregion
     ViewData["doc"] = doc;
     return(View());
 }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageOffice.WordWriter.WordDocument wordDoc = new PageOffice.WordWriter.WordDocument();

        wordDoc.OpenDataRegion("PO_company").Value = "北京幻想科技有限公司";
        wordDoc.OpenDataRegion("PO_logo").Value    = "[image]doc/logo.gif[/image]";
        wordDoc.OpenDataRegion("PO_dr1").Value     = "左边的文本:xxxx";

        PageOfficeCtrl1.SetWriter(wordDoc);// 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。
        //设置服务器页面
        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx";
        PageOfficeCtrl1.WebOpen("doc/test.doc", PageOffice.OpenModeType.docNormalEdit, "文档操作人姓名");
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageOffice.WordWriter.WordDocument wordDoc = new PageOffice.WordWriter.WordDocument();
        //获取数据区域对象后赋值
        PageOffice.WordWriter.DataRegion dataRegion1 = wordDoc.OpenDataRegion("PO_userName");
        dataRegion1.Value = "张三";

        //也可以直接赋值
        wordDoc.OpenDataRegion("PO_deptName").Value = "人事部";

        PageOfficeCtrl1.SetWriter(wordDoc);// 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。
        //设置服务器页面
        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx";
        PageOfficeCtrl1.WebOpen("doc/test.doc", PageOffice.OpenModeType.docNormalEdit, "文档操作人姓名");
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageOffice.WordWriter.WordDocument wordDoc = new PageOffice.WordWriter.WordDocument();

        //打开数据区域,OpenDataRegion方法的参数代表Word文档中的书签名称
        PageOffice.WordWriter.DataRegion dataRegion1 = wordDoc.OpenDataRegion("PO_userName");
        //设置DataRegion的可编辑性
        dataRegion1.Editing = true;

        PageOffice.WordWriter.DataRegion dataRegion2 = wordDoc.OpenDataRegion("PO_deptName");
        dataRegion2.Editing = true;

        PageOfficeCtrl1.SetWriter(wordDoc);
        //设置保存数据的页面
        PageOfficeCtrl1.SaveDataPage = "SaveData.aspx";
        //设置保存文件的页面
        PageOfficeCtrl1.SaveFilePage = "SaveFile.aspx";
        PageOfficeCtrl1.ServerPage   = Request.ApplicationPath + "/pageoffice/server.aspx";
        PageOfficeCtrl1.AddCustomToolButton("保存", "Save()", 1);
        //如果需要提交数据,必须将WebOpen的第二个参数OpenModeType设置为docSubmitForm
        PageOfficeCtrl1.WebOpen("doc/test.doc", PageOffice.OpenModeType.docSubmitForm, "文档操作人姓名");
    }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //设置服务器页面
        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx";
        PageOffice.WordWriter.WordDocument wordDoc = new PageOffice.WordWriter.WordDocument();

        //打开数据区域,OpenDataRegion方法的参数代表Word文档中的书签名称
        PageOffice.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;

        PageOffice.WordWriter.DataRegion dataRegion2 = wordDoc.OpenDataRegion("PO_deptName");
        dataRegion2.Value      = "人事部";
        dataRegion2.Font.Color = Color.Red;

        PageOfficeCtrl1.SetWriter(wordDoc);
        PageOfficeCtrl1.WebOpen("doc/test.doc", PageOffice.OpenModeType.docNormalEdit, "文档操作人姓名");
    }
Ejemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageOffice.WordWriter.WordDocument doc = new PageOffice.WordWriter.WordDocument();
        //禁用右击事件
        doc.DisableWindowRightClick = true;
        //给数据区域赋值,即把数据填充到模板中相应的位置
        doc.OpenDataRegion("PO_company").Value = "北京卓正志远软件有限公司";

        FileMakerCtrl1.ServerPage   = Request.ApplicationPath + "/pageoffice/server.aspx";
        FileMakerCtrl1.SaveFilePage = "Savemaker.aspx";
        FileMakerCtrl1.SetWriter(doc);
        FileMakerCtrl1.JsFunction_OnProgressComplete = "OnProgressComplete()";
        FileMakerCtrl1.FillDocumentAsPDF(Server.MapPath("doc/template.doc"), PageOffice.DocumentOpenType.Word, "a.pdf");
    }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageOffice.WordWriter.WordDocument doc = new PageOffice.WordWriter.WordDocument();
        //获取Table所在的数据区域对象
        PageOffice.WordWriter.DataRegion dataRegion = doc.OpenDataRegion("PO_regTable");
        //打开table,OpenTable(index)方法中的index代表Word文档中table位置的索引,从1开始
        PageOffice.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);

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

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

        PageOfficeCtrl1.SetWriter(doc);
        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx";
        PageOfficeCtrl1.WebOpen("doc/test.doc", PageOffice.OpenModeType.docNormalEdit, "张佚名");
    }
Ejemplo n.º 9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // 设置PageOffice组件服务页面
     PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx";
     //添加自定义的保存按钮
     PageOfficeCtrl1.AddCustomToolButton("保存图片", "Save", 1);
     PageOffice.WordWriter.WordDocument wordDoc     = new PageOffice.WordWriter.WordDocument();
     PageOffice.WordWriter.DataRegion   dataRegion1 = wordDoc.OpenDataRegion("PO_image");
     dataRegion1.Editing = true;//放图片的数据区域是可以编辑的,其它部分不可编辑
     PageOfficeCtrl1.SetWriter(wordDoc);
     //设置数据提交的保存页面
     PageOfficeCtrl1.SaveDataPage = "SaveData.aspx";
     // 打开文档
     PageOfficeCtrl1.WebOpen("doc/test.doc", PageOffice.OpenModeType.docSubmitForm, "Tom");
 }
Ejemplo n.º 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //PageOffice组件的引用
        //首先确保已安装了pageoffice服务器端组件,且在项目中已添加了pageoffice文件夹,
        //在该文件夹中已存在posetup.exe和server.aspx服务器端页面,再在前台页面中引入PageOfficeCtrl控件

        PageOffice.WordWriter.WordDocument worddoc = new PageOffice.WordWriter.WordDocument();
        //先在要插入word文件的位置手动插入书签,书签必须以“PO_”为前缀
        //给DataRegion赋值,值的形式为:"[word]word文件路径[/word]"
        PageOffice.WordWriter.DataRegion data1 = worddoc.OpenDataRegion("PO_p1");
        data1.Value = "[word]doc/1.doc[/word]";
        PageOffice.WordWriter.DataRegion data2 = worddoc.OpenDataRegion("PO_p2");
        data2.Value = "[word]doc/2.doc[/word]";
        PageOffice.WordWriter.DataRegion data3 = worddoc.OpenDataRegion("PO_p3");
        data3.Value = "[word]doc/3.doc[/word]";
        //设置服务器页面
        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx";
        string fileName = "test.doc";

        PageOfficeCtrl1.SetWriter(worddoc);
        PageOfficeCtrl1.Caption = "演示:后台编程插入word文件到数据区域(专业版、企业版)";
        //打开文件
        PageOfficeCtrl1.WebOpen(Server.MapPath("doc/") + fileName, PageOffice.OpenModeType.docNormalEdit, "张佚名");
    }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        docID = Request.QueryString["ID"];

        string          connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|demo.mdb";
        OleDbConnection conn       = new OleDbConnection(connString);

        conn.Open();

        string       sql = "select * from leaveRecord where ID=" + docID;
        OleDbCommand cmd = new OleDbCommand(sql, conn);

        cmd.CommandType = CommandType.Text;
        OleDbDataReader Reader = cmd.ExecuteReader();

        if (Reader.Read())
        {
            docFile       = Reader["FileName"].ToString();
            docName       = Reader["Name"].ToString();
            docDept       = Reader["Dept"].ToString();
            docCause      = Reader["Cause"].ToString();
            docNum        = Reader["Num"].ToString();
            docSubmitTime = DateTime.Parse(Reader["SubmitTime"].ToString());
        }
        Reader.Close();
        conn.Close();

        //-----------  PageOffice 服务器端编程开始  -------------------//

        PageOffice.WordWriter.WordDocument doc = new PageOffice.WordWriter.WordDocument();
        doc.DisableWindowRightClick          = true;
        doc.OpenDataRegion("PO_name").Value  = docName;
        doc.OpenDataRegion("PO_dept").Value  = docDept;
        doc.OpenDataRegion("PO_cause").Value = docCause;
        doc.OpenDataRegion("PO_num").Value   = docNum;
        doc.OpenDataRegion("PO_date").Value  = docSubmitTime.ToLongDateString();
        doc.OpenDataRegion("PO_tip").Value   = "";;

        // 设置PageOffice组件服务页面
        PageOfficeCtrl1.ServerPage = "pageoffice/server.aspx";

        // 设置界面样式
        PageOfficeCtrl1.Caption     = "动态生成格式文件";
        PageOfficeCtrl1.BorderStyle = PageOffice.BorderStyleType.BorderThin;
        // 添加自定义工具条按钮
        PageOfficeCtrl1.AddCustomToolButton("打印", "poPrint", 6);
        PageOfficeCtrl1.AddCustomToolButton("全屏/还原", "poSetFullScreen", 4);

        ////获取数据对象
        PageOfficeCtrl1.SetWriter(doc);
        // 打开文档
        PageOfficeCtrl1.WebOpen("doc/template.doc", PageOffice.OpenModeType.docReadOnly, "Tom");
        //-----------  PageOffice 服务器端编程结束  -------------------//
    }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageOffice.WordWriter.WordDocument doc = new PageOffice.WordWriter.WordDocument();
        //获取Table所在的数据区域对象
        PageOffice.WordWriter.DataRegion dataRegion = doc.OpenDataRegion("PO_regTable");
        //打开table,OpenTable(index)方法中的index代表Word文档中table位置的索引,从1开始
        PageOffice.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 = "张三";
        PageOfficeCtrl1.SetWriter(doc);
        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx";
        PageOfficeCtrl1.WebOpen("doc/test.doc", PageOffice.OpenModeType.docNormalEdit, "张佚名");
    }
Ejemplo n.º 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //设置服务器页面
        FileMakerCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx";
        string id = Request.QueryString["id"];

        if (id != null && id.Length > 0)
        {
            PageOffice.WordWriter.WordDocument doc = new PageOffice.WordWriter.WordDocument();
            //禁用右击事件
            doc.DisableWindowRightClick = true;
            //给数据区域赋值,即把数据填充到模板中相应的位置
            doc.OpenDataRegion("PO_company").Value = "北京卓正志远软件有限公司  " + id;
            //设置保存页面
            FileMakerCtrl1.SaveFilePage = "Savemaker.aspx?id=" + id;
            FileMakerCtrl1.SetWriter(doc);
            //设置转换完成后执行的JS函数
            FileMakerCtrl1.JsFunction_OnProgressComplete = "OnProgressComplete()";
            //打开文档
            FileMakerCtrl1.FillDocument(Server.MapPath("doc/template.doc"), PageOffice.DocumentOpenType.Word);
        }
    }
Ejemplo n.º 14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        docID = Request.QueryString["ID"];

        string          connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|demo.mdb";
        OleDbConnection conn       = new OleDbConnection(connString);

        conn.Open();

        string       sql = "select * from leaveRecord where ID=" + docID;
        OleDbCommand cmd = new OleDbCommand(sql, conn);

        cmd.CommandType = CommandType.Text;
        OleDbDataReader Reader = cmd.ExecuteReader();

        if (Reader.Read())
        {
            docFile       = Reader["FileName"].ToString();
            docName       = Reader["Name"].ToString();
            docDept       = Reader["Dept"].ToString();
            docCause      = Reader["Cause"].ToString();
            docNum        = Reader["Num"].ToString();
            docSubmitTime = DateTime.Parse(Reader["SubmitTime"].ToString());
        }
        Reader.Close();
        conn.Close();

        //-----------  PageOffice 服务器端编程开始  -------------------//



        PageOffice.WordWriter.WordDocument doc    = new PageOffice.WordWriter.WordDocument();
        PageOffice.WordWriter.DataRegion   drName = doc.OpenDataRegion("PO_name");
        drName.Value   = docName;
        drName.Editing = true;
        PageOffice.WordWriter.DataRegion drDept = doc.OpenDataRegion("PO_dept");
        drDept.Value = docDept;
        drDept.Shading.BackgroundPatternColor = Color.Silver;
        //drDept.Editing = true;
        PageOffice.WordWriter.DataRegion drCause = doc.OpenDataRegion("PO_cause");
        drCause.Value   = docCause;
        drCause.Editing = true;
        PageOffice.WordWriter.DataRegion drNum = doc.OpenDataRegion("PO_num");
        drNum.Value   = docNum;
        drNum.Editing = true;
        PageOffice.WordWriter.DataRegion drDate = doc.OpenDataRegion("PO_date");
        drDate.Value = docSubmitTime.ToLongDateString();
        drDate.Shading.BackgroundPatternColor = Color.Pink;
        //drDate.Editing = true;
        PageOffice.WordWriter.DataRegion drTip = doc.OpenDataRegion("PO_tip");
        drTip.Font.Italic = true;
        drTip.Value       = "提示:带背景色的文字是只能通过选择设置,[]中的文字是可以录入编辑的。";

        // 设置PageOffice组件服务页面
        PageOfficeCtrl1.ServerPage = "pageoffice/server.aspx";

        // 设置界面样式
        PageOfficeCtrl1.Caption     = "用户填写请假条";
        PageOfficeCtrl1.BorderStyle = PageOffice.BorderStyleType.BorderThin;
        // 添加自定义工具条按钮
        PageOfficeCtrl1.AddCustomToolButton("保存", "poSave", 1);
        PageOfficeCtrl1.AddCustomToolButton("全屏/还原", "poSetFullScreen", 4);

        PageOfficeCtrl1.JsFunction_OnWordDataRegionClick = "OnWordDataRegionClick()";
        // 设置保存文档的服务器页面
        PageOfficeCtrl1.SaveDataPage = "SaveData.aspx?ID=" + docID;
        ////获取数据对象
        PageOfficeCtrl1.SetWriter(doc);
        // 打开文档
        PageOfficeCtrl1.WebOpen("doc/template.doc", PageOffice.OpenModeType.docSubmitForm, "Tom");
        //-----------  PageOffice 服务器端编程结束  -------------------//
    }