Hi, |
Re: Set Clipboard in CSV format What are you trying to do? If you want to paste tables to Excel then we already have a thread where this is described. Additionally you might have luck pasting RTF (which supports tables). Do you have a special application that will only understand CSV? Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Set Clipboard in CSV format Mathias Mamsch - Fri Oct 07 16:37:10 EDT 2011 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS Eg. Word copys to the clipboard as: plain text, richtext, html, enhanced metafile etc. (displayed in 'paste special') Pasting to word - Word chooses richtext. Pasting to paint - Paint chooses enhanced metafile. Pasting to notepad - Notepad chooses plain text. So the recieving application interprets the data based on the format. It CSV data is put on the clipboard, but with the plain text format, the recieving App will not know it is CSV and will not parse it as CSV. I used CSV as an example, applications can specify their own formats which they understand. DOORS does this to copy items/objects and Word ignores the data in that format since it does not understand it. So my app wants to query the clipboard for a specific format it can decode, and 'paste' it appropriatly. Hence I want to set the Format. |
Re: Set Clipboard in CSV format SystemAdmin - Mon Oct 10 06:13:53 EDT 2011 |
Re: Set Clipboard in CSV format OurGuest - Mon Oct 10 10:28:21 EDT 2011 DXL can interact with the clipboard formats inside Drag/Drop Callbacks - I just wondered if anybody knew to to do it from outside the Callbacks. The rest is just background info. |
Re: Set Clipboard in CSV format SystemAdmin - Mon Oct 10 06:13:53 EDT 2011 Seems to me then with DXL that you would "paste" into your string variable, then write code to parse it expecting CSV format.
|
Re: Set Clipboard in CSV format llandale - Mon Oct 10 14:59:58 EDT 2011
I must have failed to explain properly.
copyToClipboard("This is not {\\b bold}?")
setRichClip(richText("This is {\\b bold}"))
string FormatName = "SomeFormat" int FormatID = registeredFormat(FormatName) string Error = setDropString(FormatID, aTrigger, "The Data" , false)
string FormatName = "SomeFormat" int FormatID = registeredFormat(FormatName) string Error = setClipboardWithFormat(FormatID, "The Data")
|
Re: Set Clipboard in CSV format SystemAdmin - Tue Oct 11 10:25:24 EDT 2011
I must have failed to explain properly.
copyToClipboard("This is not {\\b bold}?")
setRichClip(richText("This is {\\b bold}"))
string FormatName = "SomeFormat" int FormatID = registeredFormat(FormatName) string Error = setDropString(FormatID, aTrigger, "The Data" , false)
string FormatName = "SomeFormat" int FormatID = registeredFormat(FormatName) string Error = setClipboardWithFormat(FormatID, "The Data")
Ok, short answer: there is no such function in DXL. It would be interesting to hear to what application you want to paste (if you have any special application in mind). Excel for example will automatically convert your clipboard text (without the need to explicitly set your format). Pasting to Word however will give you just the text. What you could do is open Excel invisibly using create object, paste there and try to copy from there in a different format.
// paste this to excel ...
string s = "<HTML>
<BODY>
<TABLE BORDER><TR><TH ROWSPAN=2>Head1</TH><TD>Item 1
</TD><TD>Item 2</TD><TD>Item 3</TD>
<TD>Item 4</TD></TR><TR><TD>Item 5</TD>
<TD>Item 6</TD><TD>Item 7</TD><TD>Item 8</TD>
</TR><TR><TH>Head2</TH><TD>Item 9</TD>
<TD>Item 10</TD><TD>Item 11</TD><TD>Item 12</TD></TR></TABLE>
</BODY>
</HTML>"
copyToClipboard s
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Set Clipboard in CSV format Mathias Mamsch - Tue Oct 11 18:13:20 EDT 2011
Ok, short answer: there is no such function in DXL. It would be interesting to hear to what application you want to paste (if you have any special application in mind). Excel for example will automatically convert your clipboard text (without the need to explicitly set your format). Pasting to Word however will give you just the text. What you could do is open Excel invisibly using create object, paste there and try to copy from there in a different format.
// paste this to excel ...
string s = "<HTML>
<BODY>
<TABLE BORDER><TR><TH ROWSPAN=2>Head1</TH><TD>Item 1
</TD><TD>Item 2</TD><TD>Item 3</TD>
<TD>Item 4</TD></TR><TR><TD>Item 5</TD>
<TD>Item 6</TD><TD>Item 7</TD><TD>Item 8</TD>
</TR><TR><TH>Head2</TH><TD>Item 9</TD>
<TD>Item 10</TD><TD>Item 11</TD><TD>Item 12</TD></TR></TABLE>
</BODY>
</HTML>"
copyToClipboard s
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
The App is just an internally created legacy (rubbish) program someody wrote years ago that "processes data". It should be binned in my opinion! Not important now but... In Excel 2003, a paste after running your code dosen't insert a the table to cells - it put in the plaintext in rows of one column. Putting the same thing on the clipboard but with the format set to HTML does work. Seems that is the mechanism for copy pasting Word tables. Annoyingly, it splits cells with newlines over separate rows and vertically merges other cells of the HTML table row - rather than putting the newlines in one cell (as in Alt-Enter). |
Re: Set Clipboard in CSV format SystemAdmin - Wed Oct 12 08:50:15 EDT 2011 https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14627116� Maybe this helps, regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Set Clipboard in CSV format Mathias Mamsch - Wed Oct 12 12:03:02 EDT 2011 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS I have discovered something regarding Excel Paste.. Excel 2003 UK - http://Excel (11.8231.8202) SP3 I paste plaintext CSV into Excel - it all goes into 1 column. I then use the "Data > Text to Columns..." command. - Delimited, Comma, Text qualifier: " Now the data is as it should be. Now... Clear the sheet. Paste to Excel. This time it pastes to multi columns straight away. So the settings in "Data > Text to Columns..." determine how the paste works. For me, when opening Excel the these settings are on Tab not Comma which is why it didn't paste CSV as expected. I guess they could be set differently for different versions/languages. I've not found how to change these defaults yet. |
Re: Set Clipboard in CSV format SystemAdmin - Thu Oct 13 10:15:05 EDT 2011 So now we can create our own "XSV" format, where "X" is a short sequence of non-printable characters, perhaps charOf(22) "" charOf(23) "" charOf(24) "". Then get each desired cell, use that separator, past into excel, then command excel to delimit it correcly based on that sequence.
|
Re: Set Clipboard in CSV format llandale - Thu Oct 13 17:07:34 EDT 2011
Continuing to stray off topic...
string PasteStringIntoRange(OleAutoObj ObjRange, string StringToPaste)
{
OleAutoArgs autoArgs = create
OleAutoObj ObjWorksheet = null
oleGet(ObjRange, "Worksheet", ObjWorksheet)
// Lock the Clipboard
ClipboardLock LockedClipboardRef = null
while(null LockedClipboardRef)
{
LockedClipboardRef = create(2000)
if (null LockedClipboardRef)
{
if (!confirm("Failed to lock the clipboard. Retry?"))
{
break
}
}
}
string Error = ""
if(!null LockedClipboardRef)
{
noError
// Copy
if(copyToClipboard(convertToCodepage(850, StringToPaste)))
{
// Paste
clear autoArgs
put(autoArgs, "Destination", ObjRange)
oleMethod(ObjWorksheet, "Paste", autoArgs)
} else {
Error = "Failed to Copy"
}
// Unlock the Clipboard
string LastError = lastError()
Error = Error LastError
delete LockedClipboardRef
} else {
Error = "Failed to Lock the Clipboard"
}
delete autoArgs
ObjWorksheet = null
return Error
}
OleAutoObj PasteCsvIntoRange(OleAutoObj ObjRange, string CsvValues)
{
OleAutoArgs autoArgs = create
OleAutoObj ObjCellRange = null
OleAutoObj ObjPasteRange = null
// Get first cell in range
clear autoArgs
put(autoArgs, "RowIndex", 1)
oleGet(ObjRange, "Item", autoArgs, ObjCellRange)
// Put some Data in
olePut(ObjCellRange, "Value2", "SetCsvDecode")
// Run TextToColumns to change the settings
clear autoArgs
put(autoArgs, "DataType", 1) //xlDelimited
put(autoArgs, "TextQualifier", 1) //xlDoubleQuote
put(autoArgs, "Comma", true)
oleMethod(ObjCellRange, "TextToColumns", autoArgs)
// Clear the cell
oleMethod(ObjCellRange, "Clear")
// Paste the CSV
if(null(PasteStringIntoRange(ObjRange, CsvValues)))
{
// Set WrapText so multi line shows
oleGet(ObjRange, "CurrentRegion", ObjPasteRange)
olePut(ObjCellRange, "WrapText", true)
}
delete autoArgs
ObjCellRange = null
return ObjPasteRange
}
|