Sitemap

Amicuk Programming Answers

Download Internal table to Excel with different Tabs -  ole2_object

-0001-11-30   Views:0

Advertisement

Hi All, I am using  ole2_object to download the data from internal table to Excel file. As per different values in sorting key, data will be downloading in different tab in same Excel file. In my internal table one field is of character type and some

Hi All,
I am using  ole2_object to download the data from internal table to Excel file. As per different values in sorting key, data will be downloading in different tab in same Excel file.
In my internal table one field is of character type and some times contains number as value.
e.g.  itab-code = ‘000002’.
While downloading to Excel, Excel consider this value as numeric and remove the leading zero.
Any suggestions for how to set format property as ‘Text’ for this cell, will highly appreciated.
Sample  code -
   data: gs_excel type ole2_object,
         gs_wbooklist type ole2_object,
         gs_application type ole2_object,
         gs_wbook type ole2_object,
         gs_activesheet type ole2_object,
         gs_sheets type ole2_object,
         gs_newsheet type ole2_object,
         gs_cell type ole2_object.
   create object gs_excel 'EXCEL.APPLICATION'.
   get property of gs_excel 'workbooks' = gs_wbooklist.
   get property of gs_wbooklist 'Application' = gs_application.
   set property of gs_application 'SheetsInNewWorkbook' = 1.
   call method of gs_wbooklist 'Add' = gs_wbook.
   get property of gs_application 'ActiveSheet' = gs_activesheet.
   set property of gs_activesheet 'Name' = datasheet_name.
  call method of gs_excel 'Cells' = gs_cell exporting #1 = v_row           
                                          #2 = v_col.
  set property of gs_cell 'value' = <f>.
GET PROPERTY OF gs_cell 'Font' = gs_Font.
SET PROPERTY OF gs_Font 'Bold' = 1 .
Thanks.
Regards,
Meenakshi.

The replay answer
Advertisement
Hello,
Just concatenate ' infont of the fields, which you want to treat as a text.
Like,
itab-code = '00002'.
concatenate '''' itab-code  into itab-code.
modify itab.
You can also set the text properties of the cell by,
  SET PROPERTY OF gs_cell 'NumberFormat' = '@' .
but, it will remove the leading zeros and set the format as text.
Regards,
Naimesh

Go to See the other 3 answers

Hot
Hi All, I have the following problem: I have a query Q1 returning a few rows. In the group G1 using this query Q1 i have a computed field returning a number NUM_1. select col_1, col_2 from table_1; So the output looks like: row 1 col_1 col_2 NUM_1_1 [More]
Just bought a new MBP last week and gave my wife the MB. I typically attach to an external 24" display and run in closed clamshell mode. I have been doing it for quite some time with no issues. Now with the new MBP if the energy saver kicks in and tu [More]
I have probed the water for this suggestion in this thread and man, it is cold out there! The suggestion is to allow programmers to specify that a VI output connection is "required". Currently, the only options are "recommended" and &q [More]
I've decided to get a MacBook Air. I won't be purchasing for another month. But I am going to be using it to run boot camp some and for some gaming. Mainly just the sims 3. But 95% of it for school work. Now since I'll be using boot camp. With window [More]
We have got a situation here in the implementation. The client has different G/L account which are are not associated with emp. group, org. unit, job or cost center. They have different G/L account and with these they will do their budgeting & report [More]
Is there any video player that can play .avi files and also support drag&drop subtitles? I tried Perian with Quick time and now it plays .avi files perfectly. However still can't drag the subtitles to Quicktime screen. Also I tried Miro and VLC Playe [More]
Sadly, all we have for color depth in the tech specs is the same old 'support for millions of colors' which we know in the past to have been a total lie. All the laptop displays have been 6 bit color, 262,144 colors, period. A great article on 6 bit [More]
This may seem like a silly question. But, I see on the insert that it says license is only good for 1 PC use. I am SO upset that my computer crashed, and thinking about wasting $128 makes that even more upsetting.I'm not sure what "insert" you a [More]
I have my photos grouped by categories and have assigned songs to each group. How can I made a DVD of all these photos and just have certain songs play when a certain group of photos is being shown? If someone can point me to online instructions or a [More]
Hello, We currently use the ActiveSync Report to run a daily report of Hits on the Exchange 2010 SP3 RU5 CAS servers (http://blogs.technet.com/b/exchange/archive/2012/01/31/a-script-to-troubleshoot-issues-with-exchange-activesync.aspx) The script wil [More]