Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Copying an Itab to clipboard and pasting it to a range, joins the colums. How do I prevent this?

0 Kudos
1,065

Hi, I need to export an internal table to an excel file. Therefore I am using ole2_objects.

First I passed the values cell by cell, which worked like intended but had very poor performance. Even small tables took more than 10 minutes. So I did some research on how to solve the performance issue and came across the solution, to put the itab into the clipboard and then paste it to a range in ole2.

I did it like in this example only changing the row in which the range starts, since the first rows do have a picture:

https://answers.sap.com/questions/2822599/using-clipboard-in-ole.html

But now I have the problem, that in the excel file all the data from the different columns is concatenated and written as a string into the first column.

So for example if I have an Itab, where the first line looks like this: | A | B | C | the output in the excel file will look like this: | A B C | | |

My guess is, that either the method cl_gui_frontend_services=>clipboard_export writes the data to the clipboard in a way, where the ole2_objects don't recognize that there are different columns, or the paste process to the ole2_object is missing some kind of additional info. But I can't find anything on either of those topics.

How can I prevent the data from getting concatenated into a single column, when exporting it to clipboard and pasting it to the ole2_object?

Or is there an alternative to the method cl_gui_frontend_services=>clipboard_export, that I am using?

1 REPLY 1
Read only

Sandra_Rossi
Active Contributor
764

You are using OLE, ouch, not a good idea !

But well, if it's just for very simple action, you might continue using it, just add a tab character between each column, because Excel should interpret it when you paste.