IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Forms Oracle Discussion :

Exporter des données de forms vers excel


Sujet :

Forms Oracle

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 13
    Points
    13
    Par défaut Exporter des données de forms vers excel
    Bonjour,

    Version de forms : Version 10.1.2.0.2
    Version BD : Oracle 10g

    J'ai un bloc basé, et je voudrais exporté les données de ce bloc basé dans un fichier type toto.csv sur mon poste local via par exemple un bouton pour exploitation après avec excel.

    Comment faire svp ?

    Merci

  2. #2
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Bonjour,

    Pour ce faire, il faut utiliser les fonctions du package CLIENT.TEXT_IO de la librairie Webutil, qui permettent la manipulation de fichiers texte sur le poste client. La syntaxe est la même que pour le package standard TEXT_IO.
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 13
    Points
    13
    Par défaut
    Merci

  4. #4
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    238
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2002
    Messages : 238
    Points : 125
    Points
    125
    Par défaut
    bonjour,

    je suis en oracle 8
    et je ne trouve pas ce package dans la liste des SYS
    existe-t'il dans cette version ?
    A partir de quelle version d'oracle est-il disponible ?

    Si non,
    y-a-t'il un autre moyen de créer mon fichier excel

    Merci pour votre

  5. #5
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Citation Envoyé par lediz Voir le message
    bonjour,

    je suis en oracle 8
    et je ne trouve pas ce package dans la liste des SYS
    existe-t'il dans cette version ?
    A partir de quelle version d'oracle est-il disponible ?

    Si non,
    y-a-t'il un autre moyen de créer mon fichier excel

    Merci pour votre
    Il s'agit d'un package interne à Forms via sa librairie Webutil.
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  6. #6
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    238
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2002
    Messages : 238
    Points : 125
    Points
    125
    Par défaut Export FORMS vers Excel (avec OLE2.OBJ_TYPE)
    j'ai trouvé une solution avec les object " OLE2.OBJ_TYPE"

    il me reste une petit détail...bloquant !
    je n'arrive pas à donner un nom à mon fichier à son ouverture
    (sans qu'il ne se sauve automatiquement que le disque....!)
    j'ai pourtant essayé de mettre la propriété "name" à plusieurs niveaux
    (application,workbook..) ..rine a faire...

    il prend tj le nom par défaut (book1.....)

    NB : il y a juste au niveau de ma "sheet" que cela fonctionne.

    Dernière chose,la propriété visible est à "yes"
    donc excel s'ouvre automatiquement au clic du bouton et le fichier se crée "en visuel" au fure et à mesure du parcours du bloc(solution provisoire)

    pouvez-vous m'aider ?

    voici mon code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
     
    PROCEDURE Export_to_Excel(p_block_name IN VARCHAR2 DEFAULT NAME_IN('system.current_block')) IS 
     
       myTab                    CONSTANT varchar2(1) := chr(9); 
       myBlue                   CONSTANT number(8) := 16711680; --FF0000
       myGreen                  CONSTANT number(8) := 65280;    --00FF00
       myRed                    CONSTANT number(8) := 255;      --0000FF
       myDkGreen                CONSTANT number(8) := 32768;    --008000
       myBlack                  CONSTANT number(8) := 0;        --000000
     
    -- Declare the OLE objects 
    application OLE2.OBJ_TYPE; 
    workbooks OLE2.OBJ_TYPE; 
    workbook OLE2.OBJ_TYPE; 
    worksheets OLE2.OBJ_TYPE; 
    worksheet OLE2.OBJ_TYPE; 
    cell OLE2.OBJ_TYPE; 
    range OLE2.OBJ_TYPE; 
    range_col OLE2.OBJ_TYPE; 
    Font                    OLE2.OBJ_TYPE;
    hSelection                   OLE2.OBJ_TYPE;
    Workinterior                    OLE2.OBJ_TYPE;
     
     
    -- Declare handles to OLE argument lists 
    args OLE2.LIST_TYPE; 
    -- Declare form and block items 
    form_name VARCHAR2(100); 
    f_block VARCHAR2(100); 
    l_block VARCHAR2(100); 
    f_item VARCHAR2(100); 
    l_item VARCHAR2(100); 
    cur_block VARCHAR2(100) := NAME_IN('system.current_block'); 
    cur_item VARCHAR2(100) := NAME_IN('system.current_item'); 
    cur_record VARCHAR2(100) := NAME_IN('system.cursor_record'); 
    item_name VARCHAR2(100); 
    baslik VARCHAR2(100); 
    row_n NUMBER; 
    col_n NUMBER; 
    filename VARCHAR2(100) :=to_char(sysdate,'YYYMMDD_HH24MI')||'_'||p_block_name;
     
    BEGIN 
    	begin
    -- Start Excel 
    application:=OLE2.CREATE_OBJ('Excel.Application'); 
    OLE2.SET_PROPERTY(application, 'Visible', 'True'); 
    --Ole2.Set_property(application, 'Name', filename);
     
    -- Return object handle to the Workbooks collection 
    workbooks:=OLE2.GET_OBJ_PROPERTY(application, 'Workbooks'); 
     
    --
    -- Add a new Workbook object to the Workbooks collection 
    workbook:=OLE2.GET_OBJ_PROPERTY(workbooks,'Add'); 
     
    -- Return object handle to the Worksheets collection for the Workbook 
    worksheets:=OLE2.GET_OBJ_PROPERTY(workbook, 'Worksheets'); 
     
    -- Get the first Worksheet in the Worksheets collection 
    -- worksheet:=OLE2.GET_OBJ_PROPERTY(worksheets,'Add'); 
    args:=OLE2.CREATE_ARGLIST; 
    OLE2.ADD_ARG(args, 1); 
    worksheet:=OLE2.GET_OBJ_PROPERTY(worksheets,'Item', args); 
    OLE2.DESTROY_ARGLIST(args); 
    Ole2.Set_property(worksheet, 'Name', filename);
     
    /*
    Ole_Excel.worksheet := Ole2.Get_Obj_Property(Ole_Excel.application, 'ActiveSheet');
    */
     
     
    -- Return object handle to cell A1 on the new Worksheet 
    go_block(p_block_name); 
    baslik := get_block_property(p_block_name,FIRST_ITEM); 
    f_item := p_block_name||'.'||get_block_property(p_block_name, FIRST_ITEM); 
    l_item := p_block_name||'.'||get_block_property(p_block_name, LAST_ITEM); 
     
     
    first_record; 
    LOOP 
    	item_name := f_item; 
    	row_n := NAME_IN('SYSTEM.CURSOR_RECORD'); 
    	col_n := 0; 
       LOOP 
    	IF-- get_item_property(item_name,ITEM_TYPE)='TEXT ITEM' AND 
    	get_item_property(item_name,ITEM_TYPE)not in ('BUTTON','IMAGE') 
    	AND get_item_property(item_name,VISIBLE)='TRUE' 
    	THEN 
    									col_n:=col_n+1;
    									-- Set first row with the item names 
    									IF row_n=1 THEN 
    								baslik:=NVL(get_item_property(item_name,PROMPT_TEXT ),baslik); 
    	args:=OLE2.CREATE_ARGLIST; 
    	OLE2.ADD_ARG(args, row_n); 
    	OLE2.ADD_ARG(args, col_n); 
    	cell:=OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args); 
    	OLE2.DESTROY_ARGLIST(args); 
    	OLE2.SET_PROPERTY(cell, 'Value', baslik); 
    	font := OLE2.GET_OBJ_PROPERTY(cell, 'Font');
    	OLE2.SET_PROPERTY(font, 'Name', 'ARIAL');
    	OLE2.SET_PROPERTY(font, 'Size', 10);
    	OLE2.SET_PROPERTY(font, 'Bold', 'True');
                 OLE2.RELEASE_OBJ(font);
                 WorkInterior := ole2.Get_Obj_Property(cell, 'Interior');
    	OLE2.SET_PROPERTY(WorkInterior, 'ColorIndex',15);--col_n+4); 
    	OLE2.RELEASE_OBJ(WorkInterior);
    	OLE2.RELEASE_OBJ(cell); 
    	END IF; 
    	-- Set other rows with the item values 
    	args:=OLE2.CREATE_ARGLIST; 
    	OLE2.ADD_ARG(args, row_n+1); 
    	OLE2.ADD_ARG(args, col_n); 
    	cell:=OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args); 
    	OLE2.DESTROY_ARGLIST(args); 
    	IF get_item_property(item_name,DATATYPE)<>'NUMBER' THEN 
    	        OLE2.SET_PROPERTY(cell, 'NumberFormat', '@');
                 END IF; 
    	 font := OLE2.GET_OBJ_PROPERTY(cell, 'Font');
    	OLE2.SET_PROPERTY(font, 'Size', 8);
    	OLE2.SET_PROPERTY(font, 'Name', 'ARIAL');
    	OLE2.SET_PROPERTY(font, 'Bold', 'false');
    	OLE2.RELEASE_OBJ(font);
    	OLE2.RELEASE_OBJ(cell); 
             END IF; 
             IF item_name = l_item THEN  
    	exit
             END IF; 
             baslik := get_item_property(item_name,NEXTITEM); 
             item_name := p_block_name||'.'||get_item_property(item_name,NEXTITEM); 
    END LOOP; 
    EXIT WHEN NAME_IN('system.last_record') = 'TRUE'; 
    NEXT_RECORD; 
    END LOOP; 
     
    -- Autofit columns 
    range := OLE2.GET_OBJ_PROPERTY( worksheet,'UsedRange'); 
    range_col := OLE2.GET_OBJ_PROPERTY( range,'Columns'); 
    OLE2.INVOKE( range_col,'AutoFit' ); 
    OLE2.RELEASE_OBJ( range ); 
    OLE2.RELEASE_OBJ( range_col ); 
     
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG( args,filename );
    OLE2.INVOKE( worksheet,'Save',args );
    OLE2.DESTROY_ARGLIST( args );
    /*
     
    -- Get filename and path 
    args := OLE2.CREATE_ARGLIST; 
    OLE2.ADD_ARG( args, p_block_name ); 
    OLE2.ADD_ARG( args,'Excel Workbooks (*.xls, *.xls'); 
    filename := OLE2.INVOKE_CHAR(application,'GetSaveAsFilename',args ); 
    OLE2.DESTROY_ARGLIST(args); 
     
     
    -- Save as worksheet 
    args := OLE2.CREATE_ARGLIST; 
    OLE2.ADD_ARG( args,filename ); 
    OLE2.INVOKE( worksheet,'Save',args ); 
    OLE2.DESTROY_ARGLIST( args ); 
    */
     
    OLE2.Release_Obj(worksheet);
    OLE2.Release_Obj(worksheets);
    OLE2.Release_Obj(workbooks);
    OLE2.Release_Obj(application);
     
    -- Close wo
    EXCEPTION when others then begin message('exception'||substr(SQLERRM,1,200));pause;raise;end;
    end;
    end;

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2007] Macro pour exporter des données sur WORD vers Excel (version 2007)
    Par krokos55 dans le forum Macros et VBA Excel
    Réponses: 26
    Dernier message: 31/10/2012, 13h10
  2. Réponses: 35
    Dernier message: 11/08/2010, 13h13
  3. Exporter des données d'Access vers Excel.
    Par SunRay dans le forum VBA Access
    Réponses: 1
    Dernier message: 01/09/2009, 10h24
  4. Réponses: 1
    Dernier message: 08/01/2008, 14h20
  5. Réponses: 1
    Dernier message: 14/05/2007, 14h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo