如何在VB.NET中使用剪贴板获取word文档表来显示datagridview? [英] How to get word document table to display datagridview using clipboard in VB.NET?

查看:87
本文介绍了如何在VB.NET中使用剪贴板获取word文档表来显示datagridview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在vb.net中使用剪贴板概念复制word文档表



我尝试过:



我试图使用剪贴板

i want copied word document table using clipboard concept in vb.net

What I have tried:

am tried to using clipboard

My.Computer.Clipboard.GetText()

它仅适用于所选文本..如果我以字符串格式复制word文档表格,但我想要表(相同)格式。

its only good for selected text .. if i copy word document table display in string format but i want table (same ) format.

推荐答案

从Word复制到剪贴板时,数据以多种格式提供。您可以使用剪贴板查看器检查提供的格式(在Web上搜索剪贴板查看器)。



您必须选择包含所需数据的格式然后解析数据。使用表格数据,可用格式可能是CSV,HTML和RTF,其中CSV是最简单的格式,但没有任何格式信息。但我不确定这是否总是存在于Word中。 HTML和RTF也至少应包含颜色和字体信息。



要将这些格式之一的数据作为字符串使用,请使用Clipboard.GetText方法(TextDataFormat)(System.Windows.Forms) [ ^ ]传递相应的格式。



要获取任何格式的数据并检查是否存在格式,请使用Clipboard.GetDataObject Method(System.Windows.Forms) [ ^ ]方法。



第一次快速检查使用 Clipboard.GetText(TextDataFormat),所有TextDataFormat Enumeration(System.Windows.Forms) [ ^ ]值和打印字符串以查看它们包含的内容,如何解析它们以及它们是否可以用于满足您的要求。
When copying from Word to the clipboard, data is provided in multiple formats. You can use a clipboard viewer to check which formats are provided (search the web for "clipboard viewer").

You have to choose a format that contains the required data and then parse the data. With tabular data, useable formats might be CSV, HTML, and RTF where CSV is the simplest one to be parsed but without any formatting information. But I'm not sure if this is always present with Word. HTML and RTF should at least contain colour and font information too.

To get data in one of these formats as string use the Clipboard.GetText Method (TextDataFormat) (System.Windows.Forms)[^] by passing the corresponding format.

To get data in any format and check if a format is present use the Clipboard.GetDataObject Method (System.Windows.Forms)[^] method.

For a first quick check use Clipboard.GetText(TextDataFormat) with all TextDataFormat Enumeration (System.Windows.Forms)[^] values and print the strings out to see what they contain, how they might be parsed, and if they can be used fro your requirements.


这篇关于如何在VB.NET中使用剪贴板获取word文档表来显示datagridview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆