当前位置:首页
开发技术指南» 文章正文
    引言:

    摘要: 比如招行的在线支付 ......
    摘要: create proc pro_test @id char(11),@id2 char(11) as declare @@test varchar(200) declare @@test2 varchar(200) begin select @@test=count(*) from authors where au_id=@id; select @@test2=count(*) fro......


****高手关于从Word模板读取数据的问题*****(线等立结)

在建立的模板word文档中有text控件,从其中读取数据没有问题,但是如果该控件没有写值,也就是空的,读出来后显示的为“?????”,请问这个怎么转化为“”,也就是我怎么才能判断text控件的内容为空。  
  不知道说明白了没。:)

NO.1   作者: tigerwen01

在CS代码文件中对命名空间的应用,如:using   Word;范例如下:    
   
  using   System;    
  using   System.Drawing;    
  using   System.Collections;    
  using   System.ComponentModel;    
  using   System.Windows.Forms;    
  using   Word;    
   
  namespace   ExamSecure    
  {    
    ///      
    ///   ItemToDoc   的摘要说明。    
    ///      
    public   class   ItemToDoc   :   System.Windows.Forms.Form    
    {    
      object   strFileName;    
      Object   Nothing;    
      Word.ApplicationClass   myWordApp=new   Word.ApplicationClass();    
      Word.Document   myWordDoc;    
      string   strContent="";    
   
      private   System.ComponentModel.Container   components   =   null;    
   
      public   ItemToDoc()    
      {    
        //    
        //   Windows   窗体设计器支持所必需的    
        //    
        InitializeComponent();    
   
        //    
        //   TODO:   在   InitializeComponent   调用后添加任何构造函数代码    
        //    
      }    
      [STAThread]    
      static   void   Main()      
      {    
        System.Windows.Forms.Application.Run(new   ItemToDoc());    
      }    
      ///      
      ///   清理所有正在使用的资源。    
      ///      
      protected   override   void   Dispose(   bool   disposing   )    
      {    
        if(   disposing   )    
        {    
          if(components   !=   null)    
          {    
            components.Dispose();    
          }    
        }    
        base.Dispose(   disposing   );    
      }    
   
      #region   Windows   Form   Designer   generated   code    
      ///      
      ///   设计器支持所需的方法   -   不要使用代码编辑器修改    
      ///   此方法的内容。    
      ///      
      private   void   InitializeComponent()    
      {    
        //      
        //   ItemToDoc    
        //      
        this.AutoScaleBaseSize   =   new   System.Drawing.Size(6,   14);    
        this.ClientSize   =   new   System.Drawing.Size(292,   273);    
        this.Name   =   "ItemToDoc";    
        this.Text   =   "ItemToDoc";    
        this.Load   +=   new   System.EventHandler(this.ItemToDoc_Load);    
   
  }    
      #endregion    
      private   void   ItemToDoc_Load(object   sender,   System.EventArgs   e)    
      {    
        WriteFile();    
      }    
      private   void   WriteFile()    
      {    
         
        strFileName=System.Windows.Forms.Application.StartupPath+"试题库【"+GetRandomString()+"】.doc";    
        Object   Nothing=System.Reflection.Missing.Value;    
        myWordDoc=myWordApp.Documents.Add(ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing);    
           
        #region   将数据库中读取得数据写入到word文件中    
   
        strContent="试题库nnr";    
        WriteFile(strContent);    
           
        strContent="试题库";    
        WriteFile(strContent);    
   
   
        #endregion      
           
        //将WordDoc文档对象的内容保存为DOC文档    
        myWordDoc.SaveAs(ref   strFileName,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing,ref   Nothing);    
        //关闭WordDoc文档对象    
        myWordDoc.Close(ref   Nothing,   ref   Nothing,   ref   Nothing);    
        //关闭WordApp组件对象    
        myWordApp.Quit(ref   Nothing,   ref   Nothing,   ref   Nothing);    
      }    
   
      ///      
      ///   获取一个随即字符串    
      ///      
      ///      
      private   string   GetRandomString()    
      {    
        DateTime   iNow=DateTime.Now;    
        string   strDate=iNow.ToString("yyyyMMddHHmmffff");    
           
        Random   ran=new   Random();    
        int   iRan=Convert.ToInt32(10000*ran.NextDouble());    
        string   strRan=iRan.ToString();    
        //位数不足则补0          
        int   iRanlen=strRan.Length;    
        for(int   i=0;i<4-iRanlen;i++)    
        {    
          strRan="0"+strRan;    
        }    
        return   strDate+strRan;    
      }    
   
  ///      
      ///   将字符串写入到Word文件中    
      ///      
      ///   要写入的字符串    
      private   void   WriteFile(string   str)    
      {    
        myWordDoc.Paragraphs.Last.Range.Text=str;    
      }    
    }    
  }  
 


    摘要: 求:如何向数据库中,同时添加图片、图片文字说明的代码 我是一个初学者,最好能给个简单能看懂的实例. 还有同时循环显示图片、文字的代码。 请各位大虾多多帮忙啊。 ......
» 本期热门文章:
· 热门栏目:
» 相关精选文章
» 其它相关:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE