我在网上下载了一个考试的题库,不过是word文档,数据量大 我想存到数据库中请问如何才能获取到word文档中的数据?

解决方案 »

  1.   

    数据 ? Word文档?
    一般是读取excel中的数据 放到数据库? 这是读取EXCEL的代码,将EXCLE数据读到DATATABLE中,其它的你就自己写吧 
    string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                     "Data Source=" + file + ";" +
                     "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";
                OleDbDataAdapter ExcelDA = new OleDbDataAdapter("SELECT *  FROM [Sheet1$]", strConn);
                DataSet ExcelDs = new DataSet();
                try
                {
                    ExcelDA.Fill(ExcelDs, "ExcelInfo");                DataTable dt = ExcelDs.Tables[0];                return dt;            }
                catch (Exception err)
                {
                    Response.Write(err.ToString());
                }            return null;
      

  2.   

    这个读写WORD文档
    ///#region 打开Word文档,并且返回对象wDoc,wDoc 
    ///  
    /// 打开Word文档,并且返回对象wDoc,wDoc 
    ///  
    /// 完整Word文件路径+名称  
    /// 返回的Word.Document wDoc对象 
    /// 返回的Word.Application对象 
    public static void CreateWordDocument(string FileName,ref Word.Document wDoc,ref Word.Application WApp) 

    if(FileName == "") return; 
    Word.Document thisDocument = null; 
    Word.FormFields formFields = null; 
    Word.Application thisApplication = new Word.ApplicationClass(); 
    thisApplication.Visible = true; 
    thisApplication.Caption = ""; 
    thisApplication.Options.CheckSpellingAsYouType = false; 
    thisApplication.Options.CheckGrammarAsYouType = false; Object filename = FileName; 
    Object ConfirmConversions = false; 
    Object ReadOnly = true; 
    Object AddToRecentFiles = false; Object PasswordDocument = System.Type.Missing; 
    Object PasswordTemplate = System.Type.Missing; 
    Object Revert = System.Type.Missing; 
    Object WritePasswordDocument = System.Type.Missing; 
    Object WritePasswordTemplate = System.Type.Missing; 
    Object Format = System.Type.Missing; 
    Object Encoding = System.Type.Missing; 
    Object Visible = System.Type.Missing; 
    Object OpenAndRepair = System.Type.Missing; 
    Object DocumentDirection = System.Type.Missing; 
    Object NoEncodingDialog = System.Type.Missing; 
    Object XMLTransform = System.Type.Missing; try 

    Word.Document wordDoc = 
    thisApplication.Documents.Open(ref filename, ref ConfirmConversions, 
    ref ReadOnly, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate, 
    ref Revert,ref WritePasswordDocument, ref WritePasswordTemplate, ref Format, 
    ref Encoding, ref Visible, ref OpenAndRepair, ref DocumentDirection, 
    ref NoEncodingDialog, ref XMLTransform ); thisDocument = wordDoc; 
    wDoc = wordDoc; 
    WApp = thisApplication; 
    formFields = wordDoc.FormFields; 

    catch(Exception ex) 

    MessageBox.Show(ex.Message); 
    } } 
    #endregion 
      

  3.   


    this one is Excel,not for word.
    wait for the Word...
      

  4.   

    将WORD文档另存为RTF格式,然后放到数据库中,展现时使用RichTextBox控件
      

  5.   

    Word 是哪儿个命名空间的?