none
Copy datatable to clipboard

    Question

  • I want to copy a datatable to clipboard, so that I can paste directly to an excel sheet. In vb 6.0, it seems this operation was simple. We just had to copy the recordset to the clipboard and paste this to excel. The method (which might internally involve running a loop and stuff) where built-in; and it was not something I had to code for.

    I had a hunch of being able to use an ado recordset object in your managed code. (I've read it somewhere, but not used it). Is there any way I can consume the recordset object, and still maintain the disconnected nature (of ado.net) in a .net execution environment? Is it possible?

    I am a bundle of mistakes intertwined together with good intentions
    Friday, March 27, 2009 5:12 AM

Answers

All replies

  • A DataTable contains a collection of DataRows. The DataTable can be serialized to Xml, but I suspect this is not what you want. If I were you, I would simply write the resultant DataTable to an Excel file programmatically.
    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
    Friday, March 27, 2009 10:32 PM
  • For an example on how to do that, see:

    Creating/Writing to an Excel file with C#

    By the way doing it this way you can control the way it is designed rather then copying and pasting and hoping for the best.

    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
    Friday, March 27, 2009 10:42 PM