0
我试图读取文档文件在C#中的文本如何从word文件中读取文本? C#
- 我不能创建在C#中的新文件。
我尝试使用“使用Microsoft.Office.Interop.Word” 或“using System.Windows.Documents”,但它不能识别代码“Document doc = new Document”。 - 此外,如何从.docx文件读取文本?
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Office.Interop.Word; //didnt recognize "Office"
namespace DocumentTest1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
Application word = new Application();
Document doc = new Document();
}
}
可能是什么问题呢? TNX
您没有添加引用? – KeithL
选中此链接:https://stackoverflow.com/questions/3633615/how-can-i-read-docx-file – Bambuk
我添加了参考“Microsoft Office List 16.0”。我需要别的东西吗? – Olive