Datagridview与剪贴板格式化 [英] Datagridview to Clipboard with formatting

查看:271
本文介绍了Datagridview与剪贴板格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于需要将数据输出到剪贴板的VB.Net应用程序,使用格式化,我需要一些帮助。现在,我使用

For a VB.Net application needing to output the data to clipboard, with formatting, I am in need of some help. For now, I am exporting data from the clipboard using

MainView.ClipboardCopyMode = Windows.Forms.DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
System.Windows.Forms.Clipboard.SetDataObject(MainView.GetClipboardContent())

这与DataGridView的格式/样式。

Now I need to extend this with the formatting / style from the DataGridView. I have read several ExcelExporters, all writing to an Excel file directly, but I need to write to the Clipboard.

DataGridView没有公开DataGridView.GetClipBoardContent()之外的任何东西,这只是给出原始数据。我需要得到一些XML / HTML / RTF对象。我试过以下:

The DataGridView exposes nothing other than the DataGridView.GetClipBoardContent() which just gives the raw data. I need to get some XML/HTML/RTF object. I have tried the following:

Dim test As New DataObject
test.SetData(DataFormats.EnhancedMetafile , True, DataGridView1.GetClipboardContent)
Clipboard.SetDataObject(test)

任何提示,以方便地将未绑定的DataGridView转换为XML / HTML / RTF /增强的图元文件?

This does not work as of yet. Any tips to easily convert an unbound DataGridView to XML/HTML/RTF/Enhanced Metafile?

推荐答案

(你暗示),最好的是将内容呈现为HTML或RTF。 HTML表格将更适合Excel,它似乎解释得很好。

If it does not support it natively (which you imply), the best would be to render the content to HTML or RTF. HTML tables would be more suited for Excel and it seems to interpret it fairly well.

这篇关于Datagridview与剪贴板格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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