• 获取word文档或rtf格式文档的格式编码(可以应用此格式将字符以数据流的方式写入word或rtf文档)


    /// <summary>
            
    /// 生成中文字符编码
            
    /// </summary>
            
    /// <param name="ChinaStr"></param>
            
    /// <returns></returns>

            private string GetCode(string ChinaStr)
            
    {
                
    string str1="";
                System.Windows.Forms.RichTextBox myRich1
    =new RichTextBox();
                myRich1.Text
    =ChinaStr;
                myRich1.SelectAll();
                ChinaStr
    =myRich1.SelectedRtf;
                
    int count1=ChinaStr.Length ;
                
    int start1=ChinaStr.IndexOf("fs18",0,count1);
                
    if (start1==-1)
                    
    return str1;
                str1
    =ChinaStr.Substring(start1+4,count1-start1-4);
                
                
    string str3=@"{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fswiss\fcharset0 Arial;}{\f1\fnil\fcharset134 \'cb\'ce\'cc\'e5;}}
    \viewkind4\uc1\pard\lang2052\fs18\f1
    ";
                str1
    =str3+str1;
                
    return str1;
      
            }


            
    private string GetCode(string ChinaStr,System.Drawing.Font newFont  )
            
    {
                
    string str1="";
                System.Windows.Forms.RichTextBox myRich1
    =new RichTextBox();
                myRich1.Font 
    =newFont;
                myRich1.Text
    =ChinaStr;
                myRich1.SelectAll()  ;
                ChinaStr
    =myRich1.SelectedRtf;
                
    int count1=ChinaStr.Length ;
                
    int start1=ChinaStr.IndexOf(@"\fs",0,count1);
                
    if (start1==-1)
                
    {
                    
                    
    return str1;
                }

                ChinaStr
    =ChinaStr.Insert(start1+5,@"\f1");
              
                str1
    =ChinaStr ;

                
    return str1;
      
            }
  • 相关阅读:
    Java实现 LeetCode 56 合并区间
    JQuery实现对html结点的操作(创建,添加,删除)
    JQuery实现对html结点的操作(创建,添加,删除)
    JQuery实现对html结点的操作(创建,添加,删除)
    Java实现 LeetCode 55 跳跃游戏
    Java实现 LeetCode 55 跳跃游戏
    Java实现 LeetCode 55 跳跃游戏
    Java实现 LeetCode 54 螺旋矩阵
    Java实现 LeetCode 54 螺旋矩阵
    Java实现 LeetCode 54 螺旋矩阵
  • 原文地址:https://www.cnblogs.com/furenjun/p/326521.html
Copyright © 2020-2023  润新知