how to format text for copy-pasting as a spreadsheet table

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
To make bingo grids, I'm using LC to randomize and arrange a list of words
(tabs between words, cr between lines).

What I then have to do to end up with an actual spreadsheet-style grid is:

(1st) Copy-paste the LC generated text into a notepad app (Notepad++);

(2nd) Copy-paste from the notepad app to a spreadsheet app (LibreCalc);

(3rd) Copy-paste from the spreadsheet app to a document app (MS-Publisher).

My question is, can LC format text so I can skip steps 1/2 and paste the
formatted text directly into the document app and still have it appearing
as a spreadsheet grid?

And, if so, what would such formatted text look like? Some kind of HTML? If
so, please! an example.

Fingers crossed...

--
Nicolas Cueto
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
Hi.

Not sure I understand. If I make a list:

put "cat" & tab & "dog" & tab & "eel" & return & "red" & tab & "blue" & tab
& "yellow" into myList
set the clipBoardData to myList

I should be able to paste directly into any spreadsheet.

There is a thread that describes an issue pasting into google docs,
depending on the version of LC, but I do not think this ever affected Excel.

Craig Newman




--
Sent from: http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
I have code that can bypass step 1 (8.1.9 probably can too since I think
that bug fix is in there).

If you are talking about getting an actual table, then it is possible but
may require some code to pull off. I would need to do some testing to
figure out what is on the clipboard after the spreadsheet copy.
On Thu, Feb 8, 2018 at 8:41 AM dunbarx via use-livecode <
[hidden email]> wrote:

> Hi.
>
> Not sure I understand. If I make a list:
>
> put "cat" & tab & "dog" & tab & "eel" & return & "red" & tab & "blue" & tab
> & "yellow" into myList
> set the clipBoardData to myList
>
> I should be able to paste directly into any spreadsheet.
>
> There is a thread that describes an issue pasting into google docs,
> depending on the version of LC, but I do not think this ever affected
> Excel.
>
> Craig Newman
>
>
>
>
> --
> Sent from:
> http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
In reply to this post by Mike Bonner via use-livecode
You can. You will just get 2 returns instead of the one when you paste it anywhere but in an app that knows how to handle the contents of that clipboard.

Bob S


> On Feb 8, 2018, at 06:40 , dunbarx via use-livecode <[hidden email]> wrote:
>
> put "cat" & tab & "dog" & tab & "eel" & return & "red" & tab & "blue" & tab
> & "yellow" into myList
> set the clipBoardData to myList


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
See my code here:
https://github.com/bwmilby/lc-misc/blob/master/ClipboardHelper/clipboardhelper.livecodescript

"updateClipboardHtmlText" will take the HTMLText on the clipboard (which
gives the extra lines)
and replace the tags so it doesn't do that. I'm not sure if this will do
what you want though...
I've tried once before and the tabs don't get picked up this way in a
spreadsheet. It will get
rid of the extra lines, but probably place each line in a single cell.

On Thu, Feb 8, 2018 at 9:47 AM Bob Sneidar via use-livecode <
[hidden email]> wrote:

> You can. You will just get 2 returns instead of the one when you paste it
> anywhere but in an app that knows how to handle the contents of that
> clipboard.
>
> Bob S
>
>
> > On Feb 8, 2018, at 06:40 , dunbarx via use-livecode <
> [hidden email]> wrote:
> >
> > put "cat" & tab & "dog" & tab & "eel" & return & "red" & tab & "blue" &
> tab
> > & "yellow" into myList
> > set the clipBoardData to myList
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
In reply to this post by Mike Bonner via use-livecode
Craig wrote:

> I should be able to paste directly into any spreadsheet.

One would think it should, but long experience copy-pasting from/to LC
confirms "directly" just doesn't work. An intermediary step, such as a text
editor app, is always needed.

Brian wrote:

> If you are talking about getting an actual table,

Yes, that's what I'm after. Not merely a bit of tab- and cr-delimited text,
as Craig exampled, that I can copy-paste into a spreadsheet. But a bit of
text that includes not only the tab/cr-delimited text but also, for
example, indicators to show cell-borders and to centre text within a cell
vertically/horizontally.

I imagine this is somehow possible. Because, as I can do in my 3-step
method, when I copy-paste from a spreasheet doc to a word doc, not only
does the pasted text appear as an actual table but much of the cell
formatting is retained too. However, if I copy-paste that same spreadsheet
data into a text app like Notepad++, then all that appears as far as
formatting is of course the tabs and crs.

And Brian, as always, thank you for the code. I had a look, but I don't
think it achieves my final goal, i.e., getting an actual table. It's code
for cleaning up the formatting, right?

I guess I should just give up...

Thanks anyway.

--
Nicolas Cueto






On 8 February 2018 at 23:40, dunbarx via use-livecode <
[hidden email]> wrote:

> Hi.
>
> Not sure I understand. If I make a list:
>
> put "cat" & tab & "dog" & tab & "eel" & return & "red" & tab & "blue" & tab
> & "yellow" into myList
> set the clipBoardData to myList
>
> I should be able to paste directly into any spreadsheet.
>
> There is a thread that describes an issue pasting into google docs,
> depending on the version of LC, but I do not think this ever affected
> Excel.
>
> Craig Newman
>
>
>
>
> --
> Sent from: http://runtime-revolution.278305.n4.nabble.com/
> Revolution-User-f278306.html
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
Correct that my code just enables a paste into a non-plain text app without
extra lines (but colors and other formatting is retained).

Once the plain text bug fix code is released, an intermediate step will not
be needed to clean formatting as long as plain text is what was placed on
the clipboard.

Your issue should not be that difficult though. It will take a function to
do the work (with a couple loops).
On Thu, Feb 8, 2018 at 5:12 PM Nicolas Cueto via use-livecode <
[hidden email]> wrote:

> Craig wrote:
>
> > I should be able to paste directly into any spreadsheet.
>
> One would think it should, but long experience copy-pasting from/to LC
> confirms "directly" just doesn't work. An intermediary step, such as a text
> editor app, is always needed.
>
> Brian wrote:
>
> > If you are talking about getting an actual table,
>
> Yes, that's what I'm after. Not merely a bit of tab- and cr-delimited text,
> as Craig exampled, that I can copy-paste into a spreadsheet. But a bit of
> text that includes not only the tab/cr-delimited text but also, for
> example, indicators to show cell-borders and to centre text within a cell
> vertically/horizontally.
>
> I imagine this is somehow possible. Because, as I can do in my 3-step
> method, when I copy-paste from a spreasheet doc to a word doc, not only
> does the pasted text appear as an actual table but much of the cell
> formatting is retained too. However, if I copy-paste that same spreadsheet
> data into a text app like Notepad++, then all that appears as far as
> formatting is of course the tabs and crs.
>
> And Brian, as always, thank you for the code. I had a look, but I don't
> think it achieves my final goal, i.e., getting an actual table. It's code
> for cleaning up the formatting, right?
>
> I guess I should just give up...
>
> Thanks anyway.
>
> --
> Nicolas Cueto
>
>
>
>
>
>
> On 8 February 2018 at 23:40, dunbarx via use-livecode <
> [hidden email]> wrote:
>
> > Hi.
> >
> > Not sure I understand. If I make a list:
> >
> > put "cat" & tab & "dog" & tab & "eel" & return & "red" & tab & "blue" &
> tab
> > & "yellow" into myList
> > set the clipBoardData to myList
> >
> > I should be able to paste directly into any spreadsheet.
> >
> > There is a thread that describes an issue pasting into google docs,
> > depending on the version of LC, but I do not think this ever affected
> > Excel.
> >
> > Craig Newman
> >
> >
> >
> >
> > --
> > Sent from: http://runtime-revolution.278305.n4.nabble.com/
> > Revolution-User-f278306.html
> >
> > _______________________________________________
> > use-livecode mailing list
> > [hidden email]
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
In reply to this post by Mike Bonner via use-livecode
Nicolas, please don’t give up just yet, I don’t think this is too difficult. I’ve posted a sample in the user forum [ http://forums.livecode.com/viewtopic.php?f=7&t=30584 <http://forums.livecode.com/viewtopic.php?f=7&t=30584> ] that I think may work for what you describe.

The example I tried uses HTML to paste into a word type document and it works fine here, but I’m on a Mac so you will need to test carefully.

Please don’t be offended that I posted it in the beginners section, that was just because I felt it may be useful to others, and exposing new LC users to this type of action may help someone else too.

Paul

> On 8 Feb 2018, at 15:11, Nicolas Cueto via use-livecode <[hidden email]> wrote:
>
>
> I guess I should just give up...
>
> Thanks anyway.
>
> --
> Nicolas Cueto
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
Paul, thank you!

And no offense taken. I work so intermittenly with LC that whenever I take
up a new project I feel like a beginner, having to recall things I once
knew.

I'm very grateful to have this list as a resource.

--
Nicolas Cueto

On 9 February 2018 at 10:42, Paul Hibbert via use-livecode <
[hidden email]> wrote:

> Nicolas, please don’t give up just yet, I don’t think this is too
> difficult. I’ve posted a sample in the user forum [
> http://forums.livecode.com/viewtopic.php?f=7&t=30584 <
> http://forums.livecode.com/viewtopic.php?f=7&t=30584> ] that I think may
> work for what you describe.
>
> The example I tried uses HTML to paste into a word type document and it
> works fine here, but I’m on a Mac so you will need to test carefully.
>
> Please don’t be offended that I posted it in the beginners section, that
> was just because I felt it may be useful to others, and exposing new LC
> users to this type of action may help someone else too.
>
> Paul
>
> > On 8 Feb 2018, at 15:11, Nicolas Cueto via use-livecode <
> [hidden email]> wrote:
> >
> >
> > I guess I should just give up...
> >
> > Thanks anyway.
> >
> > --
> > Nicolas Cueto
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
In reply to this post by Mike Bonner via use-livecode
Hallo,
I did it in pages and its works. I had an other problem with the soft-return, it is to import text with lines in the same cells.

Can somebody tell me, how to do this. I tried with several chars, also 16 bits chars and never succeed.

Tanks

JJW
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
Could you give a little more info…

Do you want to import from Pages into LiveCode or import from LiveCode into Pages?

Paul
Paul
[hidden email]

Mac OS Sierra 10.12.1



> On Feb 13, 2018, at 3:14 AM, Jean-Jacques Wagner via use-livecode <[hidden email]> wrote:
>
> Hallo,
> I did it in pages and its works. I had an other problem with the soft-return, it is to import text with lines in the same cells.
>
> Can somebody tell me, how to do this. I tried with several chars, also 16 bits chars and never succeed.
>
> Tanks
>
> JJW
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
In reply to this post by Mike Bonner via use-livecode
Hi,
primarely from live code to pages, but also from pages to live code

Thanks
JJW

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
The best place to start is by analysing the clipBoard data, in this case, copy a small table from Pages and then look at the fullClipBoardData[“html”] in LiveCode to see how the table is represented as html.

You can then use this as a model to build a table in html and place it on the fullClipBoardData[“html”] for pasting into Pages. That’s exactly how I put together the sample posted in the forum.

By doing this I could see that to export a soft return in a cell you would need to use the HTML <p> command in place of the return within the cell.

As far as I can see, importing a table (with returns in a cell) info into LiveCode is much trickier, mainly because LiveCode doesn’t appear to support soft returns within a table cell, so the only way I can see to achieve this would probably involve a more complex workaround where each cell would have to be represented by a field object.

The part I don’t understand is how you would represent or create this data in LiveCode, do you have an example you could share?

Paul

> On Feb 14, 2018, at 4:02 AM, Jean-Jacques Wagner via use-livecode <[hidden email]> wrote:
>
> Hi,
> primarely from live code to pages, but also from pages to live code
>
> Thanks
> JJW
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
On 2/14/18 7:53 PM, Paul Hibbert via use-livecode wrote:
> As far as I can see, importing a table (with returns in a cell) info into LiveCode is much trickier, mainly because LiveCode doesn’t appear to support soft returns within a table cell,

I don't know if it applies to table cells, but LC supports soft line
breaks in fields using numToChar(11). It doesn't work when dontWrap is
true though, which may be the case in cells.

I'm still trying to figure out how to type that. If I need one in a
field I have to insert it via script.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: how to format text for copy-pasting as a spreadsheet table

Mike Bonner via use-livecode
CTRL-K is the standard keyboard equivalent, but LC does not respond to that. I suppose you can have a frontscript with a rawkeyDown handler that checks for CTRL-K (ascii 107) then put numToChar(11) into the selection. Remember to pass rawKeyDown. BTW I also use this to trap for other keys like cmd-C,X,Z,V so I can handle those functions properly when I have custom menus.

Bob S


> On Feb 15, 2018, at 24:13 , J. Landman Gay via use-livecode <[hidden email]> wrote:
>
> On 2/14/18 7:53 PM, Paul Hibbert via use-livecode wrote:
>> As far as I can see, importing a table (with returns in a cell) info into LiveCode is much trickier, mainly because LiveCode doesn’t appear to support soft returns within a table cell,
>
> I don't know if it applies to table cells, but LC supports soft line breaks in fields using numToChar(11). It doesn't work when dontWrap is true though, which may be the case in cells.
>
> I'm still trying to figure out how to type that. If I need one in a field I have to insert it via script.
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode