1. Make a Region with PL/SQL Dynamic Content type .
==========
2. Assign ID to the region using HTP.p (<span id="TEST_ID">) and Select data from table into a CLOB Type Variable and Print the variable using HTP.p
==========
Example :
HTP.p ('<a download="Subject_Info.txt" id="downloadlink" ><b>Download</b></a> <br> <br> <br>');
DECLARE
v_text CLOB;
BEGIN
HTP.p ('<span id="TEST_ID">');
FOR i
IN (SELECT EMPLOYEE_ID -- Select data from table
|| FIRST_NAME
|| LAST_NAME
|| JOB
|| HIRE_DATE
|| SALARY
|| DEPARTMENT_ID
AS Alias
FROM EMPLOYEES )
LOOP
v_text := i."Alias";
/* HTP.p ('' || replace(v_text,'&','&') || '');*/
HTP.p (''|| replace (replace (UPPER(v_text), chr (13), ''), chr (10), ' ')|| '');
END LOOP;
HTP.p ('</span>');
END;
3.Copy Pest the JavaScript code into Page >> Function and Global Variable Declaration
==========
(function () {
var textFile = null,
makeTextFile = function (text) {
var data = new Blob([text], {type: 'text/plain'});
if (textFile !== null) {
window.URL.revokeObjectURL(textFile);}
textFile = window.URL.createObjectURL(data);
return textFile;};
var create = document.getElementById('create'),
textbox = document.getElementById('TEST_ID');
var link = document.getElementById('downloadlink');
link.href = makeTextFile(textbox.innerHTML.replace(/&/g,"&").trim());
link.style.display = 'block';
})();
Click On Download
Hi, Qaium i am facing issue that it is downloading the div container as well.
ReplyDeleteHave you ever done this where code is executed from an Apex button? How would you do it?
ReplyDeleteHave you ever done this where code is executed from an Apex button? How would you do it?
ReplyDeleteI also need to keep all the CHR(13) and CHR(10). Text File is a fixed record length file with line breaks at the end
ReplyDeleteHi there, I am trying your functionality but unable to, I am using oracle apex 5.0; when i check the browser its giving unable to get inner text error and on my apex page the download link is not clickable when i place the mouse cursor on it. Can you please share your inputs on what might be causing this issue. Thanks, Raghu
ReplyDelete