Sunday, September 24, 2023

Upload Excel in database directly In Oracle Apex,Without using Wizard Easy Way

  


***************Insert Excel Data into Collection************************


begin


IF  APEX_COLLECTION.COLLECTION_EXISTS('Collection_name') THEN

    APEX_COLLECTION.TRUNCATE_COLLECTION('Collection_name');

END IF;


IF NOT APEX_COLLECTION.COLLECTION_EXISTS('Collection_name') THEN

    APEX_COLLECTION.CREATE_COLLECTION('Collection_name');

END IF; 


for r1 in (select *  from

                    apex_application_temp_files f, table( apex_data_parser.parse(

                                    p_content                     => f.blob_content,

                                    p_add_headers_row             => 'Y',

                                   -- p_store_profile_to_collection => 'FILE_PROV_CASH',

                                    p_file_name                   => f.filename,

                                      p_skip_rows => 1 ) ) p     / /This line will skip excel the first row, as I contain heading only

                where      f.name = :P3_UPLOAD_FILE  //Page Item name

                )


        loop

        APEX_COLLECTION.ADD_MEMBER(P_COLLECTION_NAME => 'Collection_name',

                                            p_c001            => nvl(REPLACE(r1.col001,'-',''),0),

                                            p_c002            => nvl(REPLACE(r1.col002,'-',''),0),

                                            P_C003            => nvl(REPLACE(r1.col003,'-',''),0),

                                            p_c004            => nvl(REPLACE(r1.col004,'-',''),0),

                                            p_c005            => nvl(REPLACE(r1.col005,'-',''),0),

                                            P_C006            => nvl(REPLACE(r1.col006,'-',''),0),

                                            p_c007            => nvl(REPLACE(r1.col007,'-',''),0),

                                            p_c008            => nvl(REPLACE(r1.col008,'-',''),0),

                                            P_C009            => nvl(REPLACE(r1.col009,'-',''),0),

                                            P_C010            => nvl(REPLACE(r1.col010,'-',''),0),

                                            P_C011            => nvl(REPLACE(r1.col011,'-',''),0),

                                            P_C012            => nvl(REPLACE(r1.col012,'-',''),0),

                                            P_C013            => nvl(REPLACE(r1.col013,'-',''),0)

                                            );

           


                

        END LOOP; 


    end;


***********Insert Collection data into Table***********


DECLARE


CURSOR C2 IS


SELECT C001, C002, C003, C004, C005, C006,

       C007, C008, C009, C010, C011, C012,

       C013, C014, C015, C016, C017, C018,

       C019, C020, C021, C022, C023, C024, C025

       

FROM APEX_COLLECTIONS 

WHERE

COLLECTION_NAME = 'Collection_name';


BEGIN


FOR I IN C2

LOOP

INSERT INTO (Table Name)

(


Table_column,   --All table column

Table_column,

Table_column,

Table_column,

Table_column,

Table_column ,

Table_column ,

Table_column ,

Table_column ,

Table_column

)

VALUES(


        I.C002,   --collection data

        I.C003, 

        I.C004, 

        I.C005,

        I.C006,

        I.C007,    

        I.C008,

        I.C009, 

        I.C010


        

);

END LOOP;

END;



*********Delete or trun collection on clear button***************


IF  APEX_COLLECTION.COLLECTION_EXISTS('Collection_name') THEN

    APEX_COLLECTION.TRUNCATE_COLLECTION('Collection_name');

END IF;  


**********Interactive Report Using Collection Data of Excel*******

 select seq_id, c001,c002,c003,c004,c005,c006,c007,c008,c009,c010,c011,c012,c013 from
 APEX_COLLECTIONS 
 WHERE COLLECTION_NAME='Collection name' and  seq_id!=1;

Saturday, September 16, 2023

image preview in apex

 --page level javascripts 


function showPreview(file, itenName) {

tet src= URL.createObjectURL,

imageContainer = $( "#${itenName}_CONTAINER .t-Form-itemWrapper" );

imageContainer.empty();

imageContainer.append("<img src=$(src) class="cc-image-preview"/>' );

}


--dynamic action P36_DISPLAY_IMAGE


let files = this.browserEvent.target.files;

if (files.length > 0){ showPreview(files[0], "P36_DISPLAY_IMAGE"); }


--inline css in apge level 


.cc-image-preview {

width: 400px;

}


--use advance column attribute  P36_DISPLAY_IMAGE

cc-image-preview 



Wednesday, September 6, 2023

Highlight empty required items

Here is how to highlight form text items, witch Value Required attribute is set to "Yes" and do not have any value.
Create dynamic action to page zero

Name: Highlight required
Event: Change
Selection Type: jQuery Selector
jQuery Selector: input[type='text'][required]
Condition: -No Condition-
Action: Execute JavaScript code
Fire On Page Load: True

Code:

if(!$v(this.triggeringElement)){
 $(this.triggeringElement).css({"border-color":"red"});
}else{
 $(this.triggeringElement).css({"border-color":""});
}


Selection Type: None

Now run application and items having Value Required set to "Yes" background color is changed if item do not have any value.
You can find Value Required setting from item attributes.



Monday, September 4, 2023

Simple Floating Button in Oracle Apex

Add following CSS into page header or in theme roller – which ever is your preference to use it.

.float{
  z-index:100;
  position:fixed;
  width:60px;
  height:60px;
  bottom:40px;
  right:40px;
  background-color: rgba(55, 76, 139, 0.81);
  color:#FFF;
  border-radius:50px;
  text-align:center;
  box-shadow: 2px 2px 3px #999;
}
.my-float{
  margin-top:22px;
}

Open your existing button and make following changes

  • Set CSS Classes as “float my-float”
  • Change Button Template to “Icon”
  • Set Icon as “fa-plus”

To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...