Datagridview 到剪贴板并格式化
对于需要将数据输出到剪贴板并进行格式化的 VB.Net 应用程序,我需要一些帮助。现在,我正在使用“
MainView.ClipboardCopyMode = Windows.Forms.DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
System.Windows.Forms.Clipboard.SetDataObject(MainView.GetClipboardContent())
现在我需要使用 DataGridView 中的格式/样式来扩展它”从剪贴板导出数据。我读过几个ExcelExporters,都是直接写入Excel文件,但我需要写入剪贴板。
DataGridView 除了仅提供原始数据的 DataGridView.GetClipBoardContent() 之外不公开任何其他内容。我需要获取一些 XML/HTML/RTF 对象。我已经尝试过以下方法:
Dim test As New DataObject
test.SetData(DataFormats.EnhancedMetafile , True, DataGridView1.GetClipboardContent)
Clipboard.SetDataObject(test)
到目前为止这还不起作用。有什么技巧可以轻松地将未绑定的 DataGridView 转换为 XML/HTML/RTF/增强型图元文件?
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())
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.
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)
This does not work as of yet. Any tips to easily convert an unbound DataGridView to XML/HTML/RTF/Enhanced Metafile?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它本身不支持(正如您所暗示的那样),最好的方法是将内容呈现为 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.
终端模块
End Module