http://www.c-sharpcorner.com/Code/2002/Mar/WordFromDotNet.asp

解决方案 »

  1.   

    我现在想读取word文件里表的内容,有没有例子呢?
      

  2.   

    Object Nothing = System.Reflection.Missing.Value; Word.Application wordapp =(Word.Application) getWordApp();
    object pathName = FullPathFileName; try
    {
    //打开Word文档
     Word.Document doc = wordapp.Documents.Open(ref pathName,ref Nothing,ref Nothing,
    ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,
    ref Nothing,ref Nothing);


    Word.Table objTable =(Word.Table) doc.Tables.Item(1);
    Word.Range objRange = (Word.Range) objTable.Cell(2,1).Range; string strRangeText = objRange.Text;
    strRangeText = strRangeText.Replace(DocumentProcessConsts.FILENO_FIND_KEY, fileNo);
    objRange.Text = strRangeText; // Word.Find objFind = (Word.Find) objRange.Find;
    //
    // objFind.ClearFormatting();
    // objFind.Text = DocumentProcessConsts.FILENO_FIND_KEY;
    // objFind.Replacement.ClearFormatting();
    // objFind.Replacement.Text = fileNo;
    // objFind.Execute(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); doc.Save();
    }
    catch( Exception e)
    {
    throw e;
    }
    finally
    {
    quitWordApp(wordapp);
    }就像这样就可以喽
      

  3.   

    简单! 见下面的HOW TO: Automate Word from Visual C# .NET to Create a New Document PSS ID Number: Q316384Article Last Modified on 02-15-2002The information in this article applies to: Microsoft Visual C# .NET (2002) 
    Microsoft Word 2000 
    Microsoft Word 2002
    For a Microsoft Visual Basic .NET version of this article, see Q316383 . 
    For a Microsoft Visual Basic 6.0 version of this article, see Q313193 .