copy from excel and paste into grid or table

General discussion forum about all things Team Developer 6.x
analiz
Turkey
Posts: 3
Joined: 09 Aug 2017, 13:59
Location: CYPRUS

copy from excel and paste into grid or table

Post by analiz » 17 Aug 2017, 11:48

Hi Friends,

As understood from the subject I would like to select the specific portion of excel and paste into Gupta table or grid. Is this possible?

Regards

Mehmet Civisilli

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 84
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: copy from excel and paste into grid or table

Post by Jeff Luther » 19 Aug 2017, 19:08

I thought I would wait to see if anyone had a full solution to your question, Mehmet, but no one replied.

There is a possible way to copy the entire XLS data -- saved in XML format -- to a TD using SalTblPopulateFromXML() but I didn't do this. You had asked for a copy/paste method of rows from XL, so let me show a way using the 3 files in the zip:
1 - 2 rows of xls data
2 - test TD in v6.3 and I back-converted it to v5.2 as well.

... Per your question, I have a way
to select the specific portion of excel and paste into Gupta table or grid
that involves a kind of workaround. Briefly, here is how:
1) Have some data in Excel or a work-alike appl. that you want to paste into a TW
2) Select the data and click Ctrl+C.

I have attached PNGs that show, top to bottom:
> the XLS data
> TD test with details of the tokenized string array of data from the field
> what the ML field and TW data look like

now from the TD test click the button which:
3) pastes the data -- for demo purposes -- into a visible ML field. (Normally, this would be invisible)
4) code then parses the data in the ML field and fills the child TW with the 2 rows of data. I added a string, 2 numbers and a datetime

NOTES:
** The assumption is that the XLS has 4 columns and that the TW has 4 matching hard-coded columns in terms of the datatypes.

** I see you must select a blank cell to the right of each cell. See the #2 PNG below to show how to do this with the sample data.

** IF YOU DO NOT select that extra blank to the right of each row, then the data paste and show correctly in the ML field BUT see the Locals window to the left of TD and where my cursor is pointing -- if there's no blank cell at end of row 1, then 2 columns' values get concatenated and paste incorrectly into the TW, as shown in attached #1 PNG.

** The code does NOT work if the user selects only certain columns from the XLS data. S/he must select entire row(s) + a blank cell at the end of each row. in the spreadsheet.

Consider this test a "Proof of Concept" appl. only. Additions to the code might include error handling of the data, dynamically creating TW columns given a single row (now to title the columns?), etc.
You do not have the required permissions to view the files attached to this post.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

analiz
Turkey
Posts: 3
Joined: 09 Aug 2017, 13:59
Location: CYPRUS

Re: copy from excel and paste into grid or table

Post by analiz » 21 Aug 2017, 04:38

Dear Jeff,
Thank you very much for the solution with an example.

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 84
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: copy from excel and paste into grid or table

Post by Jeff Luther » 21 Aug 2017, 16:19

You are welcome. I hope it will help you.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

analiz
Turkey
Posts: 3
Joined: 09 Aug 2017, 13:59
Location: CYPRUS

Re: copy from excel and paste into grid or table

Post by analiz » 25 Aug 2017, 16:06

Hi Jeff,

While I was working on your example, I come across with a Sal function which does the job a lot more easier. 'SalTblPasteRows'
The important thing here is the number of columns must match. The table columns in the grid with excel columns.

I thought you will find it helpful.

Mehmet

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 84
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: copy from excel and paste into grid or table

Post by Jeff Luther » 26 Aug 2017, 19:51

Thanks. I believe I saw that when I was coding the sample but saw the Date column value didn't paste literally from the Excel spreadsheet into the table window. But if this is not an issue, then SalTblPasteRows() does work.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

Return to “General Discussion”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests