richEditControl的使用方法

打开word 保存
 private void SelectGwSms_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable dat_gwsms = dataService.DBAccess.Query("SQL_selectksgwsmsForm_select", new string[] { str_deppostid });
                if (dat_gwsms.Rows.Count > 0)
                {
                    if (dat_gwsms.Rows[0]["fsms"].ToString() == "查看说明书")
                    {
                        string str_wjm = str_gwmc + DateTime.Now.ToLongDateString();
                        byte[] bytes = (byte[])dat_gwsms.Rows[0]["ffsms"]; //以字符流的形式下载文件


                        FileStream fs = new FileStream("c:/" + str_wjm + ".docx", FileMode.Create);//.doc,.docx
                        StreamWriter SWriter = new StreamWriter(fs, Encoding.Default);
                        fs.Write(bytes, 0, bytes.Length);
                        fs.Close();
                        richEditControl1.LoadDocument("c:/" + str_wjm + ".docx", DocumentFormat.OpenXml);
                        richEditControl1.ReadOnly = true;
                        File.Delete("c:/" + str_wjm + ".docx");
                        Document doc = richEditControl1.Document;
                        doc.BeginUpdate();
                        CharacterProperties cp = doc.BeginUpdateCharacters(0, doc.Text.Length);
                        cp.FontName = "宋体";
                        doc.EndUpdateCharacters(cp);
                        doc.EndUpdate();
                        richEditControl1.ReadOnly = true;
                        labelControl1.Text = "当前岗位为:" + str_gwmc + "" + str_jb + "";
                    }
                    else
                    {
                        richEditControl1.Text = "";
                        richEditControl1.ReadOnly = true;
                       
                    }
                }
            }
            catch (Exception ex)
            {
                Framework.Core.MessageService.ShowError(ex, "Human.HumanDepartmentPost");
            }    
        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值