display the name of column in exported .xls

Hello

I found the following code which works perfectly to export data from forms in .xls.
procedure ExportToExcel is

APPLICATION OLE2.OBJ_TYPE;
WORKBOOKS OLE2.OBJ_TYPE;
WORKBOOK OLE2.OBJ_TYPE;
WORKSHEETS OLE2.OBJ_TYPE;
WORKSHEET OLE2.OBJ_TYPE;
ARGS OLE2.LIST_TYPE;
CELL OLE2.OBJ_TYPE;
J INTEGER;
K INTEGER;
file_name_cl VARCHAR2(32767);
user_cancel EXCEPTION;
 
 
BEGIN
 
file_name_cl := CLIENT_GET_FILE_NAME('C:\rep2excel', 'MyExport.xls', 'XLS Files (.xls)|*.xls|', NULL, SAVE_FILE, TRUE);
file_name_cl := SUBSTR(file_name_cl,1,LENGTH(file_name_cl));
--
IF file_name_cl IS NULL THEN
MESSAGE('INSIDE EXCEPTION STATEMENT');
RAISE user_cancel;
END IF;
 
--MESSAGE('STARTING TRIGGER');
 
 
APPLICATION := OLE2.CREATE_OBJ('Excel.Application');
OLE2.SET_PROPERTY(APPLICATION,'Visible',True);
 
WORKBOOKS := OLE2.GET_OBJ_PROPERTY(APPLICATION, 'WORKBOOKS');
WORKBOOK := OLE2.INVOKE_OBJ(WORKBOOKS, 'ADD');
WORKSHEETS := OLE2.GET_OBJ_PROPERTY(WORKBOOK, 'WORKSHEETS');
WORKSHEET := OLE2.INVOKE_OBJ(WORKSHEETS, 'ADD');
 
GO_BLOCK('ELEVI');
 
FIRST_RECORD;
 
J:=1;
 
K:=1;
 
WHILE :SYSTEM.LAST_RECORD = 'FALSE'
 
LOOP
 
FOR K IN 1..9 --form has 9 columns
 
LOOP
 
 
If not name_in(:system.cursor_item) is NULL Then
 
args:=OLE2.create_arglist;
 
OLE2.add_arg(args, j);
 
OLE2.add_arg(args, k);
 
cell:=OLE2.get_obj_property(worksheet, 'Cells', args);
 
OLE2.destroy_arglist(args);
 
OLE2.set_property(cell, 'Value', name_in(:system.cursor_item));
 
OLE2.release_obj(cell);
 
 
End If;
 
NEXT_ITEM;
 
END LOOP;
 
 
J:=J+1;
 
NEXT_RECORD;
 
END LOOP;
 
 
-- for the last record
 
for k in 1..9
 
loop
 
If not name_in(:system.cursor_item) is NULL Then
 
args:=OLE2.create_arglist;
 
OLE2.add_arg(args, j);
 
OLE2.add_arg(args, k);
 
cell:=OLE2.get_obj_property(worksheet, 'Cells', args);
 
OLE2.destroy_arglist(args);
 
OLE2.set_property(cell, 'Value', name_in(:system.cursor_item));
 
OLE2.release_obj(cell);
 
End If;
 
next_item;
 
end loop;
 
OLE2.Release_Obj(worksheet);
 
OLE2.Release_Obj(worksheets);
 
-- Save the Excel file created
 
args := OLE2.Create_Arglist;
 
OLE2.Add_Arg(args,'c:\temp\test.xls');
 
OLE2.Invoke(workbook, 'SaveAs', args);
 
OLE2.Destroy_Arglist(args);
 
-- release workbook
 
OLE2.Release_Obj(workbook);
 
OLE2.Release_Obj(workbooks);
 
OLE2.Release_Obj(application);
 
MESSAGE('RIGHT BEFORE END');
END;
But the cells are filled with data from the 1st line. In Excel, on the 1st line, with bold, I want the name of the columns. How can I do? If the recordings should start from the 2nd line.
Any ideas?

Thank you!

Rogerrrrrrrrrr...
because there was a pause stmt. in the code... as a stmt message... remove a friend!
you don't need this funtion now that you need display all visible items in the block...

PROCEDURE l_call_Excel(p_block varchar2 ) is

APPLICATION OLE2.OBJ_TYPE;
WORKBOOKS OLE2.OBJ_TYPE;
WORKBOOK OLE2.OBJ_TYPE;
WORKSHEETS OLE2.OBJ_TYPE;
WORKSHEET OLE2.OBJ_TYPE;
Arglist OLE2.LIST_TYPE;
CELL OLE2.OBJ_TYPE;
J INTEGER;
K INTEGER;
file_name_cl VARCHAR2(32767);
user_cancel EXCEPTION;
Workfont OLE2.OBJ_TYPE;
WorkInterior OLE2.OBJ_TYPE;
m_item varchar2(40);
m_tot_columns number := 0;
--Inner Proc.
Procedure put_cell (Row_num number,
                    Col_num number,
                    put_value varchar2,
                    font_name varchar2 default null,
                    font_size binary_integer default null,
                    font_style varchar2 default null,/*here you can pass BOLD for bold, ITALIC for italic etc*/
                    font_color binary_integer default null) is
Begin
        Arglist := OLE2.create_arglist;
        OLE2.add_arg(Arglist,row_num);
        OLE2.add_arg(Arglist,col_num);
               cell := OLE2.get_obj_property(Worksheet,'Cells',Arglist);
        OLE2.destroy_arglist(Arglist);
        OLE2.set_property(cell,'Value',put_value);

        Workfont := OLE2.get_obj_property(cell,'Font');
        WorkInterior := OLE2.get_obj_property(cell,'Interior');
        If font_name is not null then
               OLE2.set_property(Workfont,'Name',font_name);
        End if;
        If font_size is not null then
               OLE2.set_property(Workfont,'Size',font_size);
        End if;
        If font_style is not null then
               OLE2.set_property(Workfont,font_style,1);
        End if;
        If font_color is not null then
               OLE2.set_property(Workfont,'ColorIndex',font_color);
        End if;
OLE2.release_obj(workfont);
OLE2.release_obj(workinterior);
OLE2.release_obj(cell);
End;

BEGIN

  file_name_cl := CLIENT_GET_FILE_NAME('C:\rep2excel', 'MyExport.xls', 'XLS Files (.xls)|*.xls|', NULL, SAVE_FILE, TRUE);
  file_name_cl := SUBSTR(file_name_cl,1,LENGTH(file_name_cl));
  --
  IF file_name_cl IS NULL THEN
     MESSAGE('INSIDE EXCEPTION STATEMENT');
     RAISE user_cancel;
  END IF;
  --MESSAGE('STARTING TRIGGER');

  APPLICATION := OLE2.CREATE_OBJ('Excel.Application');
  OLE2.SET_PROPERTY(APPLICATION,'Visible',True);

  WORKBOOKS := OLE2.GET_OBJ_PROPERTY(APPLICATION, 'WORKBOOKS');
  WORKBOOK := OLE2.INVOKE_OBJ(WORKBOOKS, 'ADD');
  WORKSHEETS := OLE2.GET_OBJ_PROPERTY(WORKBOOK, 'WORKSHEETS');
  WORKSHEET := OLE2.INVOKE_OBJ(WORKSHEETS, 'ADD');
  OLE2.set_property(Worksheet,'Name','this is my sheet, named by me');

  GO_BLOCK(p_block);
  FIRST_RECORD;
 /*as your data should print from second row*/
  J:=2;
  K:=1;
  LOOP
    m_item := get_block_property(p_block,first_item);
    K:=1;
    Loop
     exit when M_ITEM IS NULL ;
      If not id_null(find_item(p_block||'.'||m_item))  then
           If get_item_property(p_block||'.'||m_item,item_type)IN ( 'TEXT ITEM' ,'DISPLAY ITEM','LIST','CHECKBOX')
                 and get_item_property(p_block||'.'||m_item,visible) ='TRUE'   then
                If j=2 then
                put_cell(1,k,get_item_property(p_block||'.'||m_item,column_name));
              end if;
              If not name_in(p_block||'.'||m_item) is NULL Then
                put_cell(j,k,name_in(p_block||'.'||m_item));
              End If;
              K:=k+1;
             end if;
       end if;
     m_item := get_item_property(p_block||'.'||m_item,NEXTITEM );
     END LOOP;
     J:=J+1; 

   exit when :system.last_record = 'TRUE';
   NEXT_RECORD;
   END LOOP;
  OLE2.Release_Obj(worksheet);
  OLE2.Release_Obj(worksheets);
  -- Save the Excel file created
  Arglist := OLE2.Create_Arglist;
  OLE2.Add_Arg(Arglist,'c:\temp\test.xls');
  OLE2.Invoke(workbook, 'SaveAs', Arglist);
  OLE2.Destroy_Arglist(Arglist);
  -- release workbook
  OLE2.Release_Obj(workbook);
  OLE2.Release_Obj(workbooks);
  OLE2.Release_Obj(application);
  MESSAGE('RIGHT BEFORE END');
END;

Tags: Oracle Development

Similar Questions

  • Display the name of the tag as the column name and the value in the tag as a row of data from the input string.

    Hi Forum members,

    I am looking for a query display the name of the tag as the column name and the value in the tag as a row of data.

    I have to print the values within the tag to a file by choosing the value of the flags. the sequence of the tags will vary each time, as the tag name will change dynamically.

    So here is the example of input data and the expected output. The string in the text column must be separated as the column names and values.

    Input data
    Select 1 as seqno,' < > 0210A 50 4f < / 4f > < 5f20 > TEST CARD 16 < / 5f20 > < 5f2a > < / 5f2a > < 82 > 1 c 00 < / 82 > ' double text


    Output:

    Seqno 4f 5f20 5f2a 82
    0210A 50 16 1 00 TEST CARD 1

    Please help me by providing your entries on this.

    We use the version of Oracle 11.2.

    Note: This is not the XML string

    Thank you

    Shree

    with

    data in the form of

    (select 1 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2a><82>00 1' text of all the double union)

    Select 2 as seqno,'XYZ<4F>0210 A 50<5f20>TEST CARD 16<5f2a><82>00 1' text of all the double union

    Select 3 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2A><82>1 00XYZ ' text of all the double union

    Select option 4 as seqno,'<4F>0210 A 50<5F20>TEST CARD 16<5f2A><82>1 00XYZ' double text

    )

    Select d.seqno, x.*

    d the data,

    XMLTable ('/ root')

    by the way xmltransform (xmltype ('': replace (replace (text,'<><>'),)))

    XmlType (q'~http://www.w3.org/1999/XSL/Transform "version ="1.0"> ")

                                                     

                                                       

                                                         

                                                       

                                                     

                                                     

                                                       

                                                         

                                                       

                                                     

    ~'

    )

    )

    path of columns '4f' varchar2 (10) "tag4f."

    path of "5f20' varchar2 (30)"tag5f20. "

    path of '5f2a' varchar2 (10) "tag5f2a."

    path of varchar2 (10) "82" "tag82.

    ) x


    SEQNO 4f 5f20 5f2a 82
    1 0210A 50 16 TEST CARD - 1 00
    2 0210A 50 16 TEST CARD - 1 00
    3 0210A 50 16 TEST CARD - 1 00
    4 0210A 50 16 TEST CARD - 1 00

    with

    data in the form of

    (select 1 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2a><82>00 1' text of all the double union)

    Select 2 as seqno,'XYZ<4F>0210 A 50<5f20>TEST CARD 16<5f2a><82>00 1' text of all the double union

    Select 3 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2A><82>1 00XYZ ' text of all the double union

    Select option 4 as seqno,'<4F>0210 A 50<5F20>TEST CARD 16<5f2A><82>1 00XYZ' double text

    ),

    Chopper (seqno, Key, value, String) as

    (select seqno,

    regexp_substr (text,'<(.+?)>', 1, 1, null, 1),

    regexp_substr (Text,'>(.*?))

    regexp_substr (text,'<.+?>. *? ) (.*) $', 1, 1, null, 1). » <>'

    from the data

    Union of all the

    Select seqno,

    regexp_substr (String,'<(.+?)>', 1, 1, null, 1),

    regexp_substr (String,'>(.*?))

    regexp_substr (String,'<.+?>. *? ) (.*) $', 1, 1, null, 1)

    Chopper

    where regexp_substr (string,'<(.*?)>', 1, 1, null, 1) is not null

    )

    Select '4f', seqno, '5f2a', '82', '5f20.

    of (seqno, lower (key) select key, value)

    Chopper

    )

    Pivot (max (value) for key in ('4f' as '4f', '5f20' as '5f20', '5f2a' as '5f2a', "82" as "82"))

    Concerning

    Etbin

  • How can we display the name of the month in an analysis?

    Hello world

    I had a requirement to display the values of column, January, February, March...
    where are the values I have in date format. and I also show the names of months in sorting like jan, Feb, March, April, etc..
    To do in 11g. Please someone help me to solve this.


    Thank you

    Hello

    First you must add the monthname function in the formula in the column. This will give you the names of months.
    Ex-MONTHNAME("Cal Date")

    Add bin to sort, or write some case statements in the other column and sorting.
    Ex-CAs
    When MONTHNAME ("Cal Date") = "Jan" then 1
    When MONTHNAME ("Cal Date") = "February" then 2
    ...
    ...
    end

    Hope this helped / replied

    Concerning
    Young

  • How to display the name of device to the file send via Bluetooth

    I get this Message:

    Receipt of file Conformation

    You want to receive a 00:13:70:69:95:84 file?

    My Question is how it can display the name of the device not the address of the device?

    Post edited by: hazzaa

    The same situation when I want to send pictures to cell phone on my laptop. I didn't find any option how to change.

    When I send photos from mobile to mobile phone laptop computer (device name) name is displayed. Try to check the properties of the external device. Maybe you will find way to change this.

  • How to display the name of my refnum on the front?

    I write data to a file. To do this, I use ' Open/create/replace the file' to prompt the user for a file name, which is then out of my VI as a refnum. I then write strings in this file with "write to a text file.

    How to display the name of the file (including the path) on the front panel once the user has entered it?

    Michael

    Use the Refnum at the path of e/s from file-> advanced file palette. You can wire it to a path indicator.

  • Z10 Z10 ILA BlackBerry does not display the name of the caller of the stored contacts.

    My Z10 does not display the names of the callers stored in contacts with a prefix or area code. For example, an incoming call on contact JOHN SMITH, whose number is stored as + 44 7976 667668 shows not her name but just 07976 667668, but if the number of JOHN SMITH has been stored as 07976 667668 (without + 44) then the incoming call appears her name. Does anyone know how to remedy this? or is it a design error / omission by RIM?

    This is a known issue with the software currently.  Please visit KB33685

  • Computer can not display the name of the network to which it is connected.

    Hello, I'm able to get a stable access to the internet with my computer, but instead of display the name of the network, I am connected to (for reference, it is DGVB1), it says "Network 2" of what I have been able to deduce the Korean. This is why I can't connect to this computer in my homegroup?

    Clueless,

    Brian

    It was surprising, but I got the computer change the name of "Network 2" to "DGVB1," my SSID, which, for some reason, let it be detected and therefore be welcomed into the group. Weird, but at least it worked. The next issue, I'll try and work on East printers, which I believe that Norton 360 can be bothered to. in any case, thanks for the help :DD

  • Created using Microsoft keyboard layout creator of keyboard, but after installation does not display the name of my keyboard on language bar on the taskbar

    I created my keyboard with "Microsoft keyboard layout creator v.14" and I create the package. It works fine but does not display the name of my keyboard on the language bar on the taskbar

    Hello

    Follow these steps and check if that helps.

    (a) click Start and type area and the language in the search bar and press to enter.

    (b) go to keyboards and languages tab.

    (c) click on change keyboards.

    (d) now, click Add.

    (e) now under any input language, you have chosen who find and choose keyboard.

    (f) ensure that all options are listed.

    (g) if there is a check mark in the United States remove it and place a check next to the language and click Ok.

    (h) now you can check cross if the preview shows you the correct layout.

  • BlackBerry Tour 9630 smartphones does not display the name of the caller

    Hello

    I have a Tour 9630, version sw 5.0.0.732.  When the phone rings, it does not display the name of the caller, their telephone number, although this number is in my address book.  Once I answer the call, the name will be displayed.

    Naturally, I would like to know who is the caller before I answer!  :-)

    I found a few messages, ask something similar, although for different model phones.  Some of them suggest that I have to disable protection for the content... but I can't find it in the options.  Even in the User Guide, it contains instructions (go to Options > Security Options > General settings... but there is no "General settings" on my phone.)

    If anyone knows how to solve this problem, I would be very grateful!

    Kind regards

    Options > Security > encryption > include contacts.

    There could be other solutions... Try these:

    1. make sure that you set your own country code to the Phone Dialer screen > Options > smart dialing.
    Set your country code in this format: "+ xx" where xx = country code. Some countries have two or three-digit country Codes. Do not place not the '+' in the entrance of your contact.
    * In the United States, the value of this country as '+ 1' Code and place your local area code in the appropriate box (this normally the default setting in a new BB).

    2. in the same place, change the length of National number for the number of digits corresponding to your country (since some countries have less than 10 as that set by default in the BB). Check out the total numbers, less country code. Do not place not the '+' in the entrance of your contact.
    * For example, some countries have a total number to 8 (more than 3 for the country code). You must enter '8 '.

  • How to extract the names of columns in dynamic SQL

    Hi all

    Is it possible to extract all the names of columns in a dynamic query?

    In my case according to the user selections that my query will get changed (number of the column, column name and tables that everything can vary).

    So now, is it possible to retrieve all the column names of the dynamic query generated?

    I am using Oracle 11g (11.2.0.4)

    Thank you

    Shaz

    Re: Dynamic Extraction on dynamic Sql

  • How to dynamically change the names of columns LOV

    Hello

    I use JDeveloper 11.1.1.4

    I have only one requirement, while I need to change the names of columns in the list of values dynamically.

    How can I achieve it.

    Please help me.

    Kind regards

    John.

    Hello

    > But I want to change the column names 'ID' and 'Name' dynamically.

    Based on what? Condition? If Yes, have you tried to set the text for the label as an expression? If not based on the condition, you can also expose the VO to Java Impl and need a way to get the attribute and change its label.

    Arun-

  • How to write information to complete file including the names of columns in the ftp adapter using the Ombudsman?

    Hi all

    I have a requirement like the reading of the data from the DB table and put it in a location of ftp server using mediator.also file in the ftp location must be in .csv format.

    I am able to get the data from the file in .csv format.

    But here, my requirement is I want the data from the file with the names of columns (i.e. header information).

    Can someone help me in this problem.

    Thanks in advance,

    Divya.

    Hello

    I am able to get the information to complete file with column names.

    I added a code in the ftpadapter xsd file.

    nxsd:version = "NXSD".

    nxsd:stream = "chars".

    nxsd: encoding = "US-ASCII".

    nxsd:hasHeader = 'true '.

    nxsd:headerLines = "1".

    nxsd:headerLinesTerminatedBy = "${eol}.

    nxsd:outboundHeader = "empno, ename, sal, location, status ${eol} '"

    By adding the code above, I'm able to get the full file header information.

    Thank you

  • Can Lightroom displays the name of the file in a slide show

    As part of a photography club, my role is to display images on a projector for the monthly contest which is held.  As part of this process, I need to be able to display the name of the file during the slide show so that others know who the photograph belongs to which is displayed.  I can't find a way to do this via a custom slide show.

    Now 'Openness' does that very well, but later "Aperture" will die a slow and painful death as revisions of the progress of OS X in the future.  for example, Apple is no longer supports Aperture.

    If there isn't a way to do that currently in Lightroom so I hope that Adobe developers reading this and might consider adding this to a future revision.  I doubt that I would be the only member of a photography club all over the world who seek this facility in Lightroom.  The fundamental role of photography clubs is to encourage members to put to the challenge and by holding competitions to achieve this effect.  The I am involved in the club is the newest and most dynamic in our State of Western Australia and which is due to the incredible power of the founder of the club (a professional photographer of Rockingham) which constantly inspires us all.

    Hi Chrispy104,

    46 years of experience club here, ask here!

    Easy when you know how!

    In the slideshow module.

    Place a check/tick in the 'Text Overlay' Control Panel-

    Click on ABC to allow text on the screen-(cela peut être fait plus d'une fois pour avoir plusieurs zones de texte!)

    You can move, resize, make set, set the opacity, or delete text boxes when they are 'active' and surrounded by the resizing border.

    Click on the drop down Menu to a choice-

    You can simply choose "Filename" or...

    If you choose 'change... '. "you enter in the text template editor, and design you everything WHAT you want to see the.

    If you click the menu drop-down at the end of the [Preset] box in the editor, you can save the preset for future use!

  • How to display the names of files without the letters of the index? "A", "B", "C", ...

    Acrobat on the ipad dispays lines with 'A' 'B' 'C' between folder names lost limit screen space.  How can we just display the names of files?

    Currently:

    < local ipad-PDF files

    A

    Apple

    Arnie

    B

    bike

    books

    C

    cards

    Preferred:

    < local ipad-PDF files

    Apple

    Arnie

    bike

    books

    cards

    Hi John,.

    Can I know how many folders/files are there in the folder "ipad-pdfs" because if the number of files/folders is above 13 in the list, then it will display the letters of the index otherwise it won't.

    Let me know your results.

  • Hi, is it possible to change the names of files that export out of indesign while packing?

    Hi, is it possible to change the names of files that export out of indesign while packing?

    For example, I can change the "Font of the Document" folder to export as a "document-fonts"?

    I ask because our naming structure requires without capital letters and no spaces. Spaces are replaced by dashes (-).

    And it would be nice if it was always exported as needed, instead of having to go back and change the names of files.

    Thank you! Much appreciated!

    Which cannot be changed without having a bad effect,. The name "Document fonts" is special. When you compress a file with fonts in a folder using exactly this name, InDesign know that these policies should be open and will be used in the document to the other end. If you name this file anything else, InDesign ignore fonts and the recipient will have to open the fonts manually.

    If you have decided to change the folder names, you will need to do once the package created, perhaps with a script.

Maybe you are looking for

  • Cannot find drivers for Satellite M307 PSMD4Q Vista

    In the Download Center, I can not find Satellite M307 (short model No. - PSMD4Q).But even for the other Satellite M30x hasn t several drivers on the operating system Windows Vista 32 x. I need drivers for all the devices of this laptop for Win Vista

  • R button fails with new tabs

    R button doesn't work on the recently opened tabs or when you open a new tab to a link via the scroll wheel. (1) go to www.boston.com or www.nytimes.com. Click on any link with the scroll wheel. After the new tab is loaded, press the Refresh button.

  • Pavilion p6000 series p6633w: video card

    I know that my system has a pci 2.0 x 16 slot, is the 3.0 pci card work?  Sapphire Radeon R7 240 2 GB DDR3 HDMI/DVI-D/VGA with Boost PCI-Express-11216-00 - 20G graphics card

  • Windows live mail used compared to outlook express

    I prefer windows live mail. How can I remove the outlook express program that keeps popping up from time to time?

  • Windows Mail in Vista family 32 premium receives e-mail!

    My Windows Mail does not receive emails, but he sends all emails on itself, which is the only mail I get in my Inbox. In addition, by hitting the send/receive and Synchronize buttons, I get a window that says "some errors occurred while processing ta