Question How to copy/pase html to/from clipboard properly like IE or outlook?

kanaida

Member
Joined
Oct 6, 2009
Messages
15
Programming Experience
3-5
I created a small html page/string out of a datatable.

that part is fine.

however, I wanted to copy that as html so if someone opens outlook, word, excel etc.... I want to be able to paste into these programs and keep the format.

for example, if you are in excel and highlight a range, copy it to clipboard. when you paste into outlook it keeps the cells etc...

mine just pastes the raw html into the body :confused:

The only way this pastes correctly into excel is if i copy a "csv" formatted string. but that dosen't keep colors, alignmnet etc...

anyone know of a way to do this so it works universally?

and I mean without using the office PIA's because office apps were merely an example. I could be using wordpad or anything else.
 
Clipboard.SetText Method (String, TextDataFormat) (System.Windows.Forms)
TextDataFormat Enumeration (System.Windows.Forms)

As you can see you can (and have to) specify the type of text format, the text you set must comply with the format specifications.

Clipboard.SetDataObject Method (Object) (System.Windows.Forms)
DataObject Class (System.Windows.Forms)

It is common to set a data object that contains the data in multiple formats, for example if you copy from rich text the app should provide both the rtf format and the plain text format to increase usability of data that can be pasted into various types of client systems.
 
Back
Top