Clipboard to DataTable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to make a class that basically looks at the clipboard, and for the
standard types of clipboard objects (csv,text, etc), create a DataTable from
it. Not all formats will be supported but as many as possible. The idea is
to be able to convert the clipboard into a DataTable, and then pass the
DataTable to another class to do some work on it.

I have started the class here:
http://www.theoren.com/DanH/ClipBoardDataTable.cs

Right now, it only supports the DataFormats.CommaSeparatedValue which is
great for Excel.

The work I have done so far is a port of the vb.net project found here:
http://www.codeguru.com/vb/controls/vbnet_controls/datagridcontrol/article.php/c6393/

I am looking for some advice or examples that show how to convert the
following DataFormats into a DataTable or DataSet

FileDrop
Html
Text
UnicodeText

Perhaps this code would be useful to others as well so if i can support a
couple more DataFormats, I will share on CodeProject.com or similar.

Thanks,
Dan
 
Dan,

You are going to have to be a little more specific.

For example, if you do a file drop, text, or unicode text, is it assumed
that the file, or the string in the text is the XML that represents the data
set? Or is it just a random file, random strings? If it is the latter,
then you can not create a data set, since those things don't have the
structure necessary for one.

The same goes for HTML. How does one map HTML to a dataset? There
isn't anything that does this by default.

Hope this helps.
 
Nicholas,
Great question!

You are right, not all formats can be "easily" translated to a DataSet. The
CSV format is great because you can easily do this:

StreamReader srReadExcel = new
StreamReader((Stream)dataObject.GetData(DataFormats.CommaSeparatedValue));

To clarify, I am looking for advice on how i can "check" if whats on the
clipboard is in a format one could create a dataTable from. I am not
necessarily looking for code but perhaps just a conversation on approach.

In a perfect world, perhaps someone has some assumptive code about a
particular format that allows them to make a datatable from it. Anyone?

Thanks!!!!
Dan


Nicholas Paldino said:
Dan,

You are going to have to be a little more specific.

For example, if you do a file drop, text, or unicode text, is it assumed
that the file, or the string in the text is the XML that represents the data
set? Or is it just a random file, random strings? If it is the latter,
then you can not create a data set, since those things don't have the
structure necessary for one.

The same goes for HTML. How does one map HTML to a dataset? There
isn't anything that does this by default.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I want to make a class that basically looks at the clipboard, and for the
standard types of clipboard objects (csv,text, etc), create a DataTable
from
it. Not all formats will be supported but as many as possible. The idea
is
to be able to convert the clipboard into a DataTable, and then pass the
DataTable to another class to do some work on it.

I have started the class here:
http://www.theoren.com/DanH/ClipBoardDataTable.cs

Right now, it only supports the DataFormats.CommaSeparatedValue which is
great for Excel.

The work I have done so far is a port of the vb.net project found here:
http://www.codeguru.com/vb/controls/vbnet_controls/datagridcontrol/article.php/c6393/

I am looking for some advice or examples that show how to convert the
following DataFormats into a DataTable or DataSet

FileDrop
Html
Text
UnicodeText

Perhaps this code would be useful to others as well so if i can support a
couple more DataFormats, I will share on CodeProject.com or similar.

Thanks,
Dan
 
The only way to do this would be to try and load the file, string, HTML,
whatever into a DataTable. If it blows up, then you know it can't be
converted to a dataset/datatable.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Nicholas,
Great question!

You are right, not all formats can be "easily" translated to a DataSet.
The
CSV format is great because you can easily do this:

StreamReader srReadExcel = new
StreamReader((Stream)dataObject.GetData(DataFormats.CommaSeparatedValue));

To clarify, I am looking for advice on how i can "check" if whats on the
clipboard is in a format one could create a dataTable from. I am not
necessarily looking for code but perhaps just a conversation on approach.

In a perfect world, perhaps someone has some assumptive code about a
particular format that allows them to make a datatable from it. Anyone?

Thanks!!!!
Dan


Nicholas Paldino said:
Dan,

You are going to have to be a little more specific.

For example, if you do a file drop, text, or unicode text, is it
assumed
that the file, or the string in the text is the XML that represents the
data
set? Or is it just a random file, random strings? If it is the latter,
then you can not create a data set, since those things don't have the
structure necessary for one.

The same goes for HTML. How does one map HTML to a dataset? There
isn't anything that does this by default.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I want to make a class that basically looks at the clipboard, and for
the
standard types of clipboard objects (csv,text, etc), create a DataTable
from
it. Not all formats will be supported but as many as possible. The
idea
is
to be able to convert the clipboard into a DataTable, and then pass the
DataTable to another class to do some work on it.

I have started the class here:
http://www.theoren.com/DanH/ClipBoardDataTable.cs

Right now, it only supports the DataFormats.CommaSeparatedValue which
is
great for Excel.

The work I have done so far is a port of the vb.net project found here:
http://www.codeguru.com/vb/controls/vbnet_controls/datagridcontrol/article.php/c6393/

I am looking for some advice or examples that show how to convert the
following DataFormats into a DataTable or DataSet

FileDrop
Html
Text
UnicodeText

Perhaps this code would be useful to others as well so if i can support
a
couple more DataFormats, I will share on CodeProject.com or similar.

Thanks,
Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top