在word中怎么用C#代码新建一个不可编辑区域(不能复制,修改,剪切)
  word能不能像其他控件一样绑定数据库的数据源 
  
   高手指教,这是我发布的第二贴了
    最好是有C#代码

解决方案 »

  1.   

    你所说的这个如果要自己写实现起来会非常麻烦的
    给你推荐一下SOA中间件,我公司以前开发在线编辑word用的就是这个,但是是收费的。
      

  2.   

    建一个不可编辑的区域可以用  dsoframer.ocx在线编辑绑定数据  可把数据库数据读出来 然后再写入word
      

  3.   

    http://www.oracle.com/us/products/applications/autoVue/index.html
      

  4.   

    我要的是我word
      并且不是B/s的
      

  5.   

    首先添加引用:浏览》C:\Program Files\Microsoft Office\OFFICE11\MSWORD.OLB  适合office2003版本 
    使用方法:  object oMissing = System.Reflection.Missing.Value;   Word.Application oWord =new Word.Application();  oWord.Visible = false;//设置Word应用程序为不可见//新建一个Word文档
       Word.Document oDoc=oWord.Documents.Add(ref oMissing,ref oMissing ,ref oMissing,ref oMissing);    //文档内容的复制与粘贴    oDoc.Content.Copy();
        oDoc.Content.Paste()//文档的另存为oDoc.SaveAs(ref fileName,ref saveFormat,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing);//其他设置   oDoc.PageSetup.PaperSize=Word.WdPaperSize.wdPaperA3;//页面设置
       oDoc.PageSetup.Orientation=Word.WdOrientation.wdOrientLandscape;//横板还是竖板
       oDoc.PageSetup.TextColumns.SetCount(2);//分栏//关闭Word   oWord.Application.Quit(ref b,ref oMissing,ref oMissing);
       System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord);通过oDoc对象对Word文档进行操作(word能做的它都能做)进行操作里面有很多函数,有兴趣的自己研究将word文档里面的文字读入到数据库中,用.net实现:试试文件操作的类: 
    public class FileControl 

    public FileControl() 
    { } 
    /**/ 
    /// 
    /// 在根目录下创建文件夹 
    /// 
    /// 要创建的文件路径 
    public void CreateFolder(string FolderPathName) 

    if (FolderPathName.Trim().Length > 0) 

    try 

    string CreatePath = System.Web.HttpContext.Current.Server.MapPath ("../../../Images/" + FolderPathName).ToString(); 
    if (!Directory.Exists(CreatePath)) 

    Directory.CreateDirectory(CreatePath); 


    catch(Exception ex) 

    throw; 


    } /**/ 
    /// 
    /// 删除一个文件夹下面的字文件夹和文件 
    /// 
    /// 
    public void DeleteChildFolder(string FolderPathName) 

    if (FolderPathName.Trim().Length > 0) 

    try 

    string CreatePath = System.Web.HttpContext.Current.Server.MapPath (FolderPathName).ToString(); 
    if (Directory.Exists(CreatePath)) 

    Directory.Delete(CreatePath, true); 


    catch(Exception ex) 

    throw; 


    } /**/ 
    /// 
    /// 删除一个文件 
    /// 
    /// 
    public void DeleteFile(string FilePathName) 

    try 

    FileInfo DeleFile = new FileInfo(System.Web.HttpContext.Current.Server.MapPath (FilePathName).ToString()); 
    DeleFile.Delete(); 

    catch(Exception ex) 

    throw; 


    public void CreateFile(string FilePathName) 

    try 

    //创建文件夹 
    //string[] strPath= FilePathName.Split('/'); 
    //CreateFolder(FilePathName.Replace("/" + strPath[strPath.Length-1].ToString(),"")); //创建文件夹 
    FileInfo CreateFile =new FileInfo(FilePathName); //创建文件 
    if(!CreateFile.Exists) 

    FileStream FS=CreateFile.Create(); 
    FS.Close(); 


    catch(Exception ex) 

    throw; 


    /**/ 
    /// 
    /// 删除整个文件夹及其字文件夹和文件 
    /// 
    /// 
    public void DeleParentFolder(string FolderPathName) 

    try 

    DirectoryInfo DelFolder = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath (FolderPathName).ToString()); 
    if (DelFolder.Exists) 

    DelFolder.Delete(); 


    catch 



    /**/ 
    /// 
    /// 在文件里追加内容 
    /// 
    /// 
    public void ReWriteReadinnerText(string FilePathName, string WriteWord) 

    try 

    //建立文件夹和文件 
    //CreateFolder(FilePathName); 
    //CreateFile(FilePathName); 
    //得到原来文件的内容 
    FileStream FileRead = new FileStream(FilePathName, FileMode.Append,FileAccess.Write); 
    //StreamReader FileReadWord = new StreamReader(FileRead, System.Text.Encoding.Default); 
    //string OldString = FileReadWord.ReadToEnd().ToString(); 
    //OldString = OldString + WriteWord; 
    //把新的内容重新写入 
    StreamWriter FileWrite = new StreamWriter(FileRead, System.Text.Encoding.Default); 
    FileWrite.Write(WriteWord); 
    //关闭 
    FileWrite.Close(); 
    //FileReadWord.Close(); 
    FileRead.Close(); 

    catch(Exception ex) 

    // throw; 

    } /**/ 
    /// 
    /// 在文件里追加内容 
    /// 
    /// 
    public string ReaderFileData(string FilePathName) 

    try 
    { FileStream FileRead = new FileStream(System.Web.HttpContext.Current.Server.MapPath (FilePathName).ToString(), FileMode.Open, FileAccess.Read); 
    StreamReader FileReadWord = new StreamReader(FileRead, System.Text.Encoding.Default); 
    string TxtString = FileReadWord.ReadToEnd().ToString(); 
    //关闭 
    FileReadWord.Close(); 
    FileRead.Close(); 
    return TxtString; 

    catch 

    throw; 


    /**/ 
    /// 
    /// 读取文件夹的文件 
    /// 
    /// 
    /// 
    public DirectoryInfo checkValidSessionPath(string FilePathName) 

    try 

    DirectoryInfo MainDir = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath (FilePathName)); 
    return MainDir; } 
    catch 

    throw; 


      

  6.   

    选择保护word文档,并且选择节,把不需要保护的节给去掉,强制保护就可以的,只有保护选中的节
                 document.Sections[i].ProtectedForForms = false;//不需要保护的节
              document.Sections[i].ProtectedForForms = true;//要保护的节 document.Protect(WdProtectionType.wdAllowOnlyFormFields, ref noReset, ref password, ref useIRM, ref enforceStyleLock);
      

  7.   

    有从sql2008数据库中将数据导入word的好方法吗?