【发布时间】:2017-10-13 22:00:57
【问题描述】:
我正在尝试从 C# 中的文档文件中读取文本
- 我无法在 C# 中创建新文档。
我尝试使用“使用 Microsoft.Office.Interop.Word” 或“使用 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
【问题讨论】:
-
你没有添加引用?
-
我添加了参考“Microsoft Office List 16.0”。我还需要别的吗?
标签: c#