如何将剪贴板中的数据导入数组中。 [英] How to bring data in clipboard into an array.
本文介绍了如何将剪贴板中的数据导入数组中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在创建idataobject接口的引用之后,我需要将剪贴板中的单词放入一个排除原始文本中所有空格的数组中。请指教。谢谢。
这是我的第一部分代码:
after the reference of idataobject interface is created I need to bring the words in the clip board into an array excluding all the spaces in the original text. Please advice. Thank you.
here's my first part of the code:
public void ReadMsWord()
{
// variable to store file path
string filePath = null;
// open dialog box to select file
OpenFileDialog file = new OpenFileDialog();
// dilog box title name
file.Title = "Word File";
// set initial directory of computer system
file.InitialDirectory = "c:\\";
// set restore directory
file.RestoreDirectory = true;
// execute if block when dialog result box click ok button
if (file.ShowDialog() == DialogResult.OK)
{
// store selected file path
filePath = file.FileName.ToString();
}
try
{
// create word application
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
// create object of missing value
object miss = System.Reflection.Missing.Value;
// create object of selected file path
object path = filePath;
// set file path mode
object readOnly = false;
// open document
Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
// select whole data from active window document
docs.ActiveWindow.Selection.WholeStory();
// handover the data to cllipboard
docs.ActiveWindow.Selection.Copy();
// clipboard create reference of idataobject interface which transfer the data
IDataObject data = Clipboard.GetDataObject();
这里我试图从word文档导入数据。数据从word文件复制到剪贴板。
我需要将剪贴板中的单词放入一个不包括原始文本中所有空格的数组中。
Here I'm trying to import data from a word document. The data is copied from a word file to the clip board.
I need to bring the words in the clip board into an array excluding all the spaces in the original text.
推荐答案
我会开始这里如何:从剪贴板中检索数据 [ ^ ]获取数据。
基本上你会得到一个字符串。
然后如何将数据解析成有用的格式是另一回事。
I would start here How to: Retrieve Data from the Clipboard[^] for getting the data.
Basically you will get a string.
Then how to parse the data into a useful format is a different story.
这篇关于如何将剪贴板中的数据导入数组中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文