APEX_MAIL Send Results In A HTML Table

Apex 3.2
I have wriiten a procedure that sends an email with data from the apex_workspace_activity_log.
I would like to try and display this data in a table in the email.
Has anybody done this before ?
CREATE OR REPLACE PACKAGE BODY EFSAPX.p_monitor_page_times AS
  procedure pr_checkelapsed(p_elapsed in number,
                            p_toemail in varchar2) is
    v_text clob;
  begin
    wwv_flow_api.SET_SECURITY_GROUP_ID;
    for x in (select
          application_id,
          application_name,
          page_id,
          elapsed_time
          from
          apex_workspace_activity_log
          where
          application_id = 103
          and elapsed_time > p_elapsed
          and trunc(view_date) > trunc(sysdate-1)
          order by
          elapsed_time desc)
    loop
      v_text := v_text || 'Application No: ' || x.application_id ||chr(10);
      v_text := v_text || 'Application: ' || x.application_name ||chr(10);
      v_text := v_text || 'Page Id: ' || x.page_id ||chr(10);
      v_text := v_text || 'Elapsed Time: ' || x.elapsed_time ||chr(10);
      v_text := v_text || utl_tcp.crlf;
    end loop;
    apex_mail.SEND(p_to    => p_toemail,
                   p_from  => '[email protected]',
                   p_body  => v_text,
                   p_subj  => 'Elapsed Time Metric Warning');
    apex_mail.push_queue('localhost', 25);
  end pr_checkelapsed;
END p_monitor_page_times;Cheers
Gus

As Bas says, the actual HTML involved is very simple, and there's loads of documentation available for it.
I normally use SQL/XML to generate HTML fragments with embedded data:
select
    xmlserialize(
        content
        xmlelement(
            "table"
          , xmlconcat(
                xmlelement(
                    "tr"
                  , xmlconcat(
                        xmlelement("th", 'Application No')
                      , xmlelement("th", 'Application')
                      , xmlelement("th", 'Page ID')
                      , xmlelement("th", 'Elapsed Time')))
              , xmlagg(
                    xmlelement(
                        "tr"
                      , xmlconcat(
                            xmlelement("td", application_id)
                          , xmlelement("td", application_name)
                          , xmlelement("td", page_id)
                          , xmlelement("td", elapsed_time)))
                    order by elapsed_time desc)))
        indent size=2) html_table
from
    apex_workspace_activity_log
where
    application_id = :p_app_id
and elapsed_time > :p_elapsed
and trunc(view_date) > trunc(sysdate-1)This avoids a lot of tedious messing about with concatenation and/or substitution in PL/SQL code, and results in clean, valid HTML mark-up with all of the tags and any attributes in the right place. However as the <tt>apex_mail</tt> API docs note, the <tt>p_body_html</tt> parameter must be a full HTML document (and you'll probably need to include other content and styling as well as the table). It's a bit tedious to nest all of that structure into the query, so a combination of using Bas' template method for the basic HTML document structure and this SQL/XML query approach to generate the table structure with data would be a good idea.
I'm guessing from the <tt>wwv_flow_api.SET_SECURITY_GROUP_ID</tt> call that you intend to run this outside of an APEX session? Another option to consider is to create a public page in this app or as a standalone app in the workspace with this query as a report region using simplified page/report templates, and all of the required styling embedded in the page. The mail procedure can then use <tt>httpUriType.getCLOB</tt> to retrieve this page as a complete document that can be passed as <tt>p_body_html</tt> to <tt>apex_mail.send</tt>.
Note the requirement that each line in the content cannot exceed 1000 characters. Whatever method you use will have to have that built in to whatever template/queries are used (hence <tt>indent</tt> in the code above), or you'll have to process the content and insert CRLFs at appropriate points before calling <tt>apex_mail.send</tt>.

Similar Messages

  • Query results to HTML table

    I'm looking for a more efficient way to convert a query result into an HTML table so that I can paste it into an email. The procedure in sqldeveloper (version 3.1.07) is just too clunky and involves too many keystrokes and mouse clicks. And you can't save the HTML to the clipboard. (I'm talking about the "Export..." action here.)
    Am I missing something? Are there any alternatives?
    Thanks!

    ... but sqlplus is so last millenium....
    Seriously? I'm from the last millennium too, nevertheless I don't consider myself out of date
    SQL*PLUS is still my first choice when I have to run a script. I'ts behaviour is reliably the same whereever my script is executed. I would never trust a script that needs another tool to be executed.
    Generating a HTML-mail is IMHO out of scope for a database tool. It's a feature I would expect in a BI tool that specializes on reporting.
    Regards
    Marcus

  • Sending an email with html tags in it using apex_mail.send

    Hello,
    I am using APEX_MAIL.SEND to send emails from my apex applications.
    now I need the email body to have html features: bold, underline, colors etc.
    If I use regular html tags, they show up in the email.
    How can this be done?
    Thanks
    Rani

    Hi, try
    p_body_html
    and it should display just fine :)

  • Help! How to send Dynamic HTML table as an email?!

    hi
    i want to send a dynamic html table as an email
    i am using php/mysql and have a mysql database
    i have a dynaimc table contins some data from the database
    i have a form with textbox to write the email in and a submit button
    i want to send the the table (or the information in the table) when i submit the form
    is that possible???
    plz help!

    Ok, now I have you.  You create a queary to select the data you want, then use this code
    $data = mysqli_query($dbc, $query) or die(mysqli_error($dbc));
    while ($row = mysqli_fetch_array($data))    {
    //Sending Email to form owner
    $header = "From: [email protected]\n"
      . "Reply-To: $email\n";
    $subject = "Data From DB into email";
    $email_to = "[email protected]";
    $message =
    $row['first_name'].
       $row['last_name']
    mail($email_to, $subject ,$message ,$header ) ;
    So for each column, you will enter this
    $row['first_name'].
    So if the column is state, you would put
    $row['state'].
    Hopefully this is the answer you were looking for.
    Gary

  • Show results from the database to html tables?

    Hi,
    I am a PHP programmer and did a successful CMS program for a company. Now I have another project which is a web based system.
    I basically know how to do it and finish it in PHP.. but I am trying to do it using J2EE.. I am trying to learn J2EE now since I have been programming
    on J2SE for quite sometime..
    I am trying to show the results from a MySQL database on a table on J2EE but I am having hard time doing that. I am trying to research online and reading books but with no luck I can't find any resources on how to do that..If you guys can lead me into a resource where I can read how to do it? or just give any ideas on how to do it correctly I'll try to read and learn I will very much appreciate it.. here's my coding please look at it. Thank you very much
    I want to make it like this in a html table:
    userid username activated task
    1 alvin y delete(this will be a link to delete the user)
    Right now this is what I was able to do so far:
    Userid username activated task
    1
    alvin
    y
    Here are my codes... I am not even sure if I am doing it in the correct way...
    User.java
    mport java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    public class Users {
    public List getUsers(){
    List names = new ArrayList();
    try{
    Connection con = DBConnect.getConnection();
    Statement stmt = con.createStatement();
    String sql = "select * from users";
    ResultSet rs = stmt.executeQuery(sql);
    while(rs.next())
    String userid = rs.getString("user_id");
    String usernames = rs.getString("user_name");
    String password= rs.getString("password");
    String activated= rs.getString("activated");
    names.add(userid);
    names.add(usernames);
    names.add(password);
    names.add(activated);
    catch(SQLException e)
    System.out.print(e);
    catch(Exception e)
    System.out.print(e);
    return names;
    UserServlet.java
    import java.io.IOException;
    import java.util.List;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class UsersServ extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Users be =new Users();
    List result = be.getUsers();
    request.setAttribute("user_results", result);
    RequestDispatcher view = request.getRequestDispatcher("manage_users1.jsp");
    view.forward(request, response);
    manage_users1.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@page import = "java.util.*" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    List results = (List)request.getAttribute("user_results");
    Iterator it = results.iterator();
    out.print("<table border = 1>");
    out.print("<th>");
    out.print("userid");
    out.print("</th>");
    out.print("<th>");
    out.print("username");;
    out.print("</th>");
    while(it.hasNext()){
    out.print("<tr><td> " + it.next()+"</td></tr>");
    out.print("</table>");
    %>
    </body>
    </html>

    I suggest:
    1: you use this:
    e.printStackTrace()
    instead of this:
    System.out.print(e);
    so it will tell you what line it crashed on.
    2: In the code below,here is how you mix coding html tags and java scriptlets
    (you should never have to use out.print()):. In a later project, you can learn how to use JSTL
    instead of java scriplets (I suggest using java scriptlets for now until you have more JSP experience).
    FROM:
    <html>
    <%
    //some java code goes here
    out.print("<th>");
    //some more java code goes here
    out.print("<tr>");
    %>
    TO:
    <html>
    <% //some java code goes here%>
    <th>
    <%//some more java code goes here%>
    <tr>
    3: Put a lot of System.println() statements in your *.java classes to verify what its doing (you can learn how to use a debugger later).
    4: I highly recommend reading a book on JSP/servlets cover to cover.
    Here's a simple MVC design approach I previously posted:
    http://forums.sun.com/thread.jspa?messageID=10786901

  • Query in Servlet not displaying results in html table

    Hi,
    I am aware that putting html in a servlet is not good practice. In my case, it is just for testing purposes.
    Environment: WLS 12c on Windows, DB 11.2.0.3
    I created an html form and a servlet in a Dynamic Web Project. The form parameters are sent to the servlet,
    but the results are not being displayed.
    HTML form:
    <input text name="p_1"
    Servlet:
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    * Servlet implementation class QueryServlet
    @WebServlet("/QueryServlet")
    public class QueryServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
         * @see HttpServlet#HttpServlet()
        public QueryServlet() {
            super();
            // TODO Auto-generated constructor stub
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            Connection conn = null;
            Statement stmt = null;
            try {
                conn = DriverManager.getConnection("jdbc:oracle:thin:@home-server:1521:val01", "USER", "PW");
                stmt = conn.createStatement();
    String sqlStr = "SELECT....
    ... WHERE p_1 =
    +  "'" + request.getParameter("p_1") + "'"
    out.println("<html><head><title>Query Results</title></head><body>");
                out.println("<p>Your query is: " + sqlStr + "</p>");
                out.println("<p>Your are connected to: " + conn + "</p>");
    --> OUTPUT ONLY UNTIL HERE <--           
                // Get data
                ResultSet rset = stmt.executeQuery(sqlStr);
                int count = 0;
                while(rset.next()){
                    int cid  = rset.getInt("CID");
    // Display data in html table
    out.println("<table>");
                    out.println("<tr>");
                    out.println("<td>" + cid + "</td>");
    rset.close();
                out.println("<p>====== " + count + " records found =======</p>");
                out.println("</body></html>");
                 catch (SQLException ex) {
                    ex.printStackTrace();
                    finally {
                        out.close();
                        try {
                            if (stmt != null) stmt.close();
                            if (conn != null) conn.close();
                        } catch (SQLException ex) {
                            ex.printStackTrace();
    Help greatly appreciated. Thanks!

    Possibly, the js file is not being detected by the javascript runtime.It would be better if you tried something like :
    ("<script src="<%=request.getContextPath()%>/WEB-INF/classes/ua.js"></script>

  • How to pass query result to HTML table?

    Hi,
      i want to get the query result in HTMl table instead of Display Grid. how to do it? i searched in help, it suggests use icommand to do this. but i dont know how to pass the select query result to HTML table.. please help me.
    -senthil

    Hi Senthil,
    You can create an icommand query. You can then use the icommand retrieval methods to capture and manipulate the query data.
    (http://help.sap.com/saphelp_xmii115/helpdata/en/Applet_Reference_Details/iCom
    mand_Reference.htm)
    Basically what we did was, use the getColumnCount() and getRowCount() methods, once you have these two numbers you can set two for loops and use String getValue(int ColID, int RowID) , within the for loops you can generate the inner html content and write the values either in a html table or html form (which is what we did). This seems to work well, I'm still playing around with it and may post this approach on sdn by end of this week.
    Mahwish

  • "Apex_Mail.Send" with table in body

    Hi
    I would like to use the APEX_MAIL.SEND and fill the body with a table.
    Something like this:
    declare
    begin
    APEX_MAIL.SEND(
      p_to =>'my_test@just_debugging.com',
      p_from=>'my_test@just_debugging.com',
      p_body=>  chr(10)||
      APEX_UTIL.TABLE_TO_STRING(my_Table, ',') || chr(10)  || -- <- This does NOT work
      TO_CHAR(Select * from My_Table),  -- <- This does NOT work
      p_subj=>'My Subject');
    -- push the e-mail queue for immediate delivery
    wwv_flow_mail.push_queue(
    P_SMTP_HOSTNAME => 'ip',
    P_SMTP_PORTNO => 'port');
    end;Does anybody knwo how to do this?

    Sorry ...
    DECLARE
       p_vc_arr2   htmldb_application_global.vc_arr2;
       p_string    VARCHAR2 (2000);
    BEGIN
    SELECT ename
       BULK COLLECT INTO p_vc_arr2
         FROM emp
        WHERE deptno = :p84_select_deptno; -- Or remove condition.
       p_string :=
         HTMLDB_UTIL.table_to_string (p_vc_arr2, ':');
    APEX_MAIL.SEND(
      p_to =>'my_test@just_debugging.com',
      p_from=>'my_test@just_debugging.com',
      p_body=>  p_string
      p_subj=>'My Subject');
    -- push the e-mail queue for immediate delivery
    wwv_flow_mail.push_queue(
    P_SMTP_HOSTNAME => 'ip',
    P_SMTP_PORTNO => 'port');
    end;In http://apex.oracle.com/pls/otn/f?p=31517:84:2900701551472314
    It should be something like this....

  • Need to send HTML table via email

    Hi Experts,
    I am using the FM EFG_GEN_SEND_EMAIL to send email but unable to send html content through this. I know I could use SO_SEND_OBJECT FM too which automatically sends the email in HTML format but it doesn't have from option(FROM EMAIL ID)
    I tired manually chaning the format from RAW to HTM via debugging and then found that its sending the html format email.
    Request you to please let me know if we could achieve the same.
    Thanks,
    Rajwin

    Hi,
    rcently we idd this requirment .
    But every thing we did it from ABAP side   not from WDJ Side
    Generation of PDF after enterring the data will be send via email along with PDF Data so try to use  Smart Forms
    Regards,
    Govindu

  • Apex_mail.send / HTML formatting Ignored When Sent via Trigger

    I have a PL/SQL procedure that sends a formatted email using the apex_mail.send procedure. This procedure works 100% perfectly if I run the procedure either from a scheduled job (using dbms_scheduler), or when I siimply call the procedure "ad hoc" from the APEX SQL Editor. However, when the exact same procedure gets invoked/called from a DB trigger, some of the formatting instructions get ignored with regards to font face and font size. I am stumped by this. Any ideas?
    BTW, I'm using APEX 4.2.
    Thanks in advance

    Sorry totally my fault - no issue at all... more a problem with the tester! users with an external email address are receiving the email it just seems when the email is sent from Apex standalone is appears in the inbox but when it is sent from within an iframe it is sent straight to the junk mail by the email client... still a little strange there is a difference in behaviour but at least it doesn't totally fail as I first thought.

  • Creating a selectable HTML table with Sahrepoint list data dind

    Hi All,
    I m creating an app for sharepoint2013 , on my app I want to read data from SP list and display on something like HTML table/ grid view.
    What I have done is as follows.
    <table cellpadding="0" cellspacing="0" border="0" class="display" id="TermList">
                        <thead>
                            <tr>
                                        <th>Start Date</th>
                                <th>End Date</th>
                                <th>Term Type(s)</th>
                                <th>Specialty</th>
                                <th width="12%">Sub Specialty</th>
                            </tr>
                        </thead>
                                            <tbody>
                            </tbody>
    </table>
    var context = SP.ClientContext.get_current();
    var user = context.get_web().get_currentUser();
    var Termsitems, web, hostcontext, currentusertitle;
    var hosturl;
    (function () {
    $(document).ready(function () {
        gethostdata();
        getUserName();
        $('#TermList').dataTable(
                        "sScrollY": 200,
                            This will enable jQuery UI theme
                        "bJQueryUI": true,
                            will add the pagination links
                        "sPaginationType": "full_numbers"
        getTermdetails();
    function gethostdata() {
        hosturl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
        context = new SP.ClientContext.get_current();
        hostcontext = new SP.AppContextSite(context, hosturl);
        web = hostcontext.get_web();
        context.load(web, 'Title');
        context.executeQueryAsync(onSiteLoadSuccess, onQueryFailed);
    function onSiteLoadSuccess(sender, args) {
        //   alert("site title : " + web.get_title());
    function onQueryFailed(sender, args) {
        alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
    function getQueryStringParameter(urlParameterKey) {
        var params = document.URL.split('?')[1].split('&');
        var strParams = '';
        for (var i = 0; i < params.length; i = i + 1) {
            var singleParam = params[i].split('=');
            if (singleParam[0] == urlParameterKey)
                return decodeURIComponent(singleParam[1]);
    // This function prepares, loads, and then executes a SharePoint query to get the current users information
    function getUserName() {
        context.load(user);
        context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
    // This function is executed if the above call is successful
    // It replaces the contents of the 'message' element with the user name
    function onGetUserNameSuccess() {
    currentusertitle= user.get_title();
      $('#message').text('Hello ' + user.get_title());
    // This function is executed if the above call fails
    function onGetUserNameFail(sender, args) {
        alert('Failed to get user name. Error:' + args.get_message());
    function getTermdetails() {
        var Termlist = web.get_lists().getByTitle("TraineeTermsSPlist");
        context.load(Termlist)
        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name="Title" />' +
                                 '<Value Type="Text"> + currentusertitle + </Value></Eq></Where></Query></View>');
        Termsitems = Termlist.getItems(camlQuery);
        context.load(Termsitems);
        context.executeQueryAsync(getTermdetailsQuerySuccsess, getTermdetailsQueryFails)
    function getTermdetailsQuerySuccsess(sender, args) {
        var listEnumerator = Termsitems.getEnumerator();
        var datatable = document.getElementById("TermList");
        while (listEnumerator.moveNext()) {
            var oListItem = listEnumerator.get_current();
            var startdate = listEnumerator.get_current().get_item('startdate');
            var enddate = listEnumerator.get_current().get_item('Enddate');
            var termtype = listEnumerator.get_current().get_item('TermType');       
            var Specialty = listEnumerator.get_current().get_item('Specialty');
            var Specialty = listEnumerator.get_current().get_item('Subspecialty');
            $("#TermList").append("<tr align='middle'  class='gradeA'>" +
                                      "<td align='left'>" + startdate +
    "</td>" +
                                      "<td align='left'>" + enddate + "</td>"
    +
                                      "<td align='left'>" + termtype + "</td>"
    +
                                      "<td align='left'>" + Specialty +
    "</td>" +
                                      "<td align='left'>" + Specialty +
    "</td>" + "</tr>");
    function getTermdetailsQueryFails(sender, args) {
        alert(' Error:' + args.get_message());
    Now what I want to do is allow user to select rows on the table. Once they select a row I want to get that selected row and search SP list based on the selected value.  Also I would like to make this table with search area to search records.
    Can someone please help me to do this, or are there any easy way to do this. Sample code or useful link much appreciate.
    Thank you very much.
    d.n weerasinghe

    Instead of writing in dive each and every time directly,
    just have a div in html, and inside the while loop
    write and store in the variable like
      output += "<li><a href='#' style='display:none'>" + usernames[i] + " </a> "
                         + "<table id='results' width='100%'>"
                         + "
    <tr style='border-bottom:1px silver solid;'>"
                         + "
    <td style='width:60px;height:70px;' >"
                         + "
    <img alt=\"profile pic\" src= '" + pictureuri[i] + "'  style='width:60px;height:60px;'/>"
                         + "
    </td>"
                         + "
    <td >"
                         + "
    <table style='height:100%'>"
                         + "
    <tr>"
                         + "
    <td style='padding-padding-vertical-align:top;height:10px' >"
                         + "
    <a href='" + personaluri[i] + "' classq='ms-bold ms-subtleLink' style='color: gray; font-size: 12px; font-weight: bold;'>" + tempnames[i] + "</a>"
                         + "
    </td>"
                         + "
    </tr>"
                         + "
    <tr>"
                         + "
    <td  style='padding-vertical-align:top;height:50px;color:#ADAEAD;font-size:14px;' >" + deptNames[i]
                         + "
    </td>"
                         + "
    </tr>"
                         + "
    </table>"
                         + "
    </td>"
                         + "
    </tr>"
                         + "</table>"
                         + "</li>"
    and finaly oyutside the loop 
    $(#div).html(output);

  • Problem in generating HTML tables in apex

    Hi friends,
    I coulnt able to generate an email in the HTML table format with a background color since im receiving only in a plain text manner.
    The below is the coding only based on HTML in which i can able to view it in the HTML tables and this is it
    <html>
    <head><title>Report 1</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <base href="http://erpdev01.ti.com:7777/pls/apex/" />
    <style type="text/css">
    table.apex_ir_html_export {
    background-color:#F2F2F5;
    border-width:1px 1px 0px 1px;
    border-color:#C9CBD3;
    border-style:solid;
    table.apex_ir_html_export td {
    color:#000000;
    font-family:Tahoma,Arial,Helvetica,Geneva,sans-serif;
    font-size:9pt;
    background-color:#EAEFF5;
    padding:8px;
    background-color:#F2F2F5;
    border-color:#ffffff #ffffff #cccccc #ffffff;
    border-style:solid solid solid solid;
    border-width:1px 0px 1px 0px;
    table.apex_ir_html_export th {
    font-family:Tahoma,Arial,Helvetica,Geneva,sans-serif;
    font-size:9pt;
    padding:8px;
    background-color:#CFE0F1;
    border-color:#ffffff #ffffff #cccccc #ffffff;
    border-style:solid solid solid none;
    border-width:1px 0px 1px 0px;
    white-space:nowrap;
    </style>
    </head>
    <style type="text/css">
    body{font-family: Arial, Helvetica, sans-serif;
                        font-size:10pt;
                        margin:30px;
                        background-color:#ffffff;}
    span.sig{font-style:italic;
    font-weight:bold;
    color:#811919;}
    </style>
    </head>
    <body>
    <table border="0" cellpadding="0" cellspacing="0" class="apex_ir_html_export">
    <thead><tr><th id=></th><th id=></th></tr></thead>
    <tr>
    <td>Employee Number</td>
    <td>:P36_EMPLOYEE_NUMBER</td>
    </tr>
    <td>Reason</td>
    <td>:P36_REASON</td>
    </tr>
    <td>Position Title</td>
    <td>:P36_POSITION_TITLE</td>
    </tr>
    <td>Qualification Displayed</td>
    <td>:P36_QUALIFICATION_DISPLAYED</td>
    </tr>
    <td>Qualification Title</td>
    <td>:P36_QUALIFICATION_TITLE</td>
    </tr>
    <td>Mobile Number</td>
    <td>:P36_MOBILE_NUMBER</td>
    </tr>
    <td>Desk Number</td>
    <td>:P36_DESK_NUMBER</td>
    </tr>
    <td>Fax Number</td>
    <td>:P36_FAX_NUMBER</td>
    </tr>
    <td>Email Address</td>
    <td>:P36_EMAIL</td>
    </tr>
    <td>Effective Date</td>
    <td>:P36_EFFECTIVE_DATE</td>
    </tr>
    <td>Location</td>
    <td>:P36_LOCATION</td>
    </tr>
    <td>Type-I</td>
    <td>:P36_TYPE1</td>
    </tr>
    <td>Type-II</td>
    <td>:P36_TYPE2</td>
    </tr>
    <td>Status</td>
    <td>:P36_STATUS</td>
    </tr>
    </table>
    </body>
    </html>
    kindly ignore div class="jive-quote" and div
    as it is generated by the forum software in the above coding. The above is working perfectly as i can able to see it in the table manner with a background color.
    The same thing it needs to work on in apex while clicking the button, the html table with contents has to be send as an email when an button is pressed, i tried with the below coding, but i couldnt able to see the HTML table with a background color, it is showing in the plain text only. it is not showng html table with a background color in it. This is the coding.
    DECLARE
    l_mail_id NUMBER;
    l_body VARCHAR2(4000);
    l_body_html VARCHAR2(4000);
    BEGIN
    l_body_html := '<html>'||
    ' <head><title>Report 1</title>'||
    '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'||
    '<base href="http://erpdev01.ti.com:7777/pls/apex/" />'||
    '<style type="text/css">'||
    'table.apex_ir_html_export {'||
    'background-color:#F2F2F5;'||
    'border-width:1px 1px 0px 1px;'||
    'border-color:#C9CBD3;border-style:solid;}'||
    'table.apex_ir_html_export td {'||
    'color:#000000;'||
    'font-family:Tahoma,Arial,Helvetica,Geneva,sans-serif;'||
    'font-size:9pt;'||
    'background-color:#EAEFF5;'||
    'padding:8px;'||
    'background-color:#F2F2F5;'||
    'border-color:#ffffff #ffffff #cccccc #ffffff;'||
    'border-style:solid solid solid solid;'||
    'border-width:1px 0px 1px 0px;'||
    '}'||
    'table.apex_ir_html_export th {'||
    'font-family:Tahoma,Arial,Helvetica,Geneva,sans-serif;'||
    'font-size:9pt;'||
    'padding:8px;'||
    'background-color:#CFE0F1;'||
    'border-color:#ffffff #ffffff #cccccc #ffffff;'||
    'border-style:solid solid solid none;'||
    'border-width:1px 0px 1px 0px;'||
    'white-space:nowrap;'||
    '}'||
    '</style>'||
    '</head>'||
    '<style type="text/css">'||
    'body{font-family: Arial, Helvetica, sans-serif;'||
                        'font-size:10pt;'||
                        'margin:30px;'||
                        'background-color:#ffffff;}'||
    'span.sig{font-style:italic;'||
    'font-weight:bold;'||
    'color:#811919;}'||
    '</style>'||
    '</head>'||
    '<body>'||utl_tcp.crlf;
    l_body_html :=
    '<table border="0" cellpadding="0" cellspacing="0" class="apex_ir_html_export">'||
    '<thead><tr><th id=></th><th id=></th></tr></thead>'||
    '<tr><td>Employee Number</td><td>'||:P36_EMPLOYEE_NUMBER||'</td></tr>'||
    '<tr><td>Reason</td><td>'||:P36_Reason||'</td></tr>'||
    '<td>Position Title</td><td>'||:P36_POSITION_TITLE||'</td></tr>'||
    '<td>Qualification Displayed</td><td>'||:P36_QUALIFICATION_DISPLAYED||'</td></tr>'||
    '<td>Qualification Title</td><td>'||:P36_QUALIFICATION_TITLE||'</td></tr>'||
    '<td>Mobile Number</td><td>'||:P36_MOBILE_NUMBER||'</td></tr>'||
    '<td>Desk Number</td><td>'||:P36_DESK_NUMBER||'</td></tr>'||
    '<td>Fax Number</td><td>'||:P36_FAX_NUMBER||'</td></tr>'||
    '<td>Email Address</td><td>'||:P36_EMAIL||'</td></tr>'||
    '<td>Effective Date</td><td>'||:P36_EFFECTIVE_DATE||'</td></tr>'||
    '<td>Location</td><td>'||:P36_LOCATION||'</td></tr>'||
    '<td>Type-I</td><td>'||:P36_TYPE1||'</td></tr>'||
    '<td>Type-II</td><td>'||:P36_TYPE2||'</td></tr>'||
    '<td>Status</td><td>'||:P36_STATUS||'</td></tr></table>'||utl_tcp.crlf;
    l_body_html := l_body_html ||'<p>Thank you for your interest in the <strong>APEX MAIL</strong></p>'||utl_tcp.crlf;
    l_body_html := l_body_html ||' Sincerely,
    '||utl_tcp.crlf;
    l_body_html := l_body_html ||' <span class="sig">The APEX Dev Team</span>
    '||utl_tcp.crlf;
    l_body := 'Request for an Salary Certificate Request'||utl_tcp.crlf;
    l_mail_id := apex_mail.send(
    p_to => '<[email protected]>',
    p_bcc => '<[email protected]>',
    p_from => :P36_EMAIL,
    p_body => l_body,
    p_body_html => l_body_html,
    p_subj => 'Salary Certificate Request With Request No' ||:P36_DIS_REQ_ID
    apex_mail.push_queue();
    END;
    kindly ignore div class="jive-quote" and div in the above codings too.
    Why it is not generating in a table via email, what is the issue.
    Thanks
    Saro.
    Edited by: Saro on May 17, 2011 12:50 PM

    Hello Saro,
    first of all: the html code you are generating is not valid html. There is no closing body and html tag. Ther eis one closing head tag to much. In your table many opening row tags are missing.
    second: have a closer look at what you are doing with your variable l_body_html. At first, you add your styles to it and then you overwrite it with your table instead of adding it.
    Regards,
    Dirk

  • Export to excel with javascript/vbscript or with plsql(html table)

    i have searched for a way to export data from OracleXe to excel without losing formatting .
    So far i have found 2 possible relatively easy ways that i am still researching
    (i do not include the ask tom sylk format way of exporting )
    1 to export the query to a html table, while using stylesheets for formatting
    (using microsoft specific styles)
    2. use of javascript/vbscript to fill an array and write this array to excel with use
    of visual basic for applications in excel.This also provides charting capabilities.
    I am still researching this two ways, and have
    encountered a few obstacles (help would be appreciated)
    1 the first way:
    a. create a button " export to excel"
    b. create the following pl/sql procedure:
    owa_util.mime_header('application/vnd.ms-excel');
    owa_util.http_header_close;
      HTP.PRINT('<html>');
      HTP.PRINT('<head>');
      HTP.PRINT('<meta http-equiv="Content-Type" content="text/html">');
      HTP.PRINT('<title>Title of the HTML File</title>');
      HTP.PRINT('</head>');
      HTP.PRINT('<body TEXT="#000000" BGCOLOR="#FFFFFF">');
      HTP.PRINT('<h1>Heading in the HTML File</h1>');
      HTP.PRINT('<p>Some text in the HTML file.');
      HTP.PRINT('</body>');
      HTP.PRINT('</html>');
    htmldb_application.g_page_text_generated := true;
    htmldb_application.g_unrecoverable_error := true;
    c: run the procedure conditionally based on the button  "export to excel"
    the problem with this way is that using htmldb_application.g_unrecoverable_error := true; is not the ideal way, because it
    stops further processing, but if i leave it out, the export doesn't happen.
    To export to excel while retaining data formatting  you have to use microsoft excel
    specific styles(Seedocumentation on the microsoft site)
    2.The second way:
    a create a pl/sql procedure or sql query.
    b use this query to fill a vbscript/javascript array with values
    c write these values to excel with use of vba in excel :
    the obstacle i encountered here was that i dont know how to export the result of a
    query to a visual basic script or javascript array.

    Using approach 1) works fine for me.
    the problem with this way is that using htmldb_application.g_unrecoverable_error := true;
    is not the ideal way, because it
    stops further processing, but if i leave it out, the export doesn't happen. Why is this a problem?
    I created the button to export the excel file on page 1 and created your pl/sql procedure on page 2 using an onload process.
    Works fine.
    Other approaches for exporting to excel are:
    http://www.oracle.com/technology/pub/articles/saternos_broadcast.html
    http://htmldb.oracle.com/pls/otn/f?p=18326:54:5685133631021176591::::P54_ID:1962
    ~Dietmar.

  • How can i display collection of  records in HTML Table using DWR framework

    Dear All,
    Just i start using the Direct Web Remoting framework.I am worrying to get the list of records to display html table using this concept.I did the same like.
    index.js
    var cellFuncs = [
    function(data) { return data; },
    function(data) { return data.toUpperCase(); },
    function(data) { return "<input type='button' value='Test' onclick='alert(\"Hi\");'/>";  },
    function(data) { return count++; }
    function update() {
    var name = dwr.util.getValue("demoName");
    Demo.sayHello(name, function(data) {    dwr.util.setValue("demoReply", data);   } );
    var count = 1;
    dwr.util.addRows( "tabs",[ 'Africa', 'America', 'Asia', 'Australasia', 'Europe' ], cellFuncs);
    alert("hai");
    index.jsp
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script type='text/javascript' src='dwr/engine.js'> </script>
    <script type='text/javascript' src='dwr/util.js'> </script>
    <script type='text/javascript' src='dwr/interface/Demo.js'> </script>
    <script type="text/javascript" src='index.js'> </script>
    </head>
    <body>
    <div id="tabContents">
    <div id="demoDiv">
    <p>
    Name:
    <input type="text" id="demoName" value="Joe"/>
    <input value="Send" type="button" onclick="update()"/>
    Reply: <span id="demoReply" style="background:#eeffdd; padding-left:4px; padding-right:4px;"></span>
         <table id="tabl1">
         <tbody id="tabs">
         <tr>
         <td>name</td>
         <td>name1</td>
         <td>name2</td>
         <td>name3sdf</td>
         </tr>
         <tbody>
         </table>
    </p>
    </div>
    </div>
    </body>
    </html>
    dwr.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd">
    <dwr>
    <allow>
    <!-- simpletext -->
    <create creator="new" javascript="Demo">
    <param name="class" value="org.getahead.dwrdemo.simpletext.Demo"/>
    </create>
    </allow>
    </dwr>
    web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app id="dwr">
    <display-name>DWR (Direct Web Remoting)</display-name>
    <description>A Simple Demo DWR</description>
    <servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <display-name>DWR Servlet</display-name>
    <description>Direct Web Remoter Servlet</description>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>activeReverseAjaxEnabled</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>initApplicationScopeCreatorsAtStartup</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>maxWaitAfterWrite</param-name>
    <param-value>500</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>
    </web-app>
    Demo.java
    package org.getahead.dwrdemo.simpletext;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import org.directwebremoting.WebContext;
    import org.directwebremoting.WebContextFactory;
    public class Demo
    public String sayHello(String name)
    return "Hello, " + name;
    the sayHello() is printing the display.But the table rows not updating.But its object expected.So can you tell me where i need to change and how to add the pagination for the table like 10 by 10 records to display.
    Please help me.
    Saravanan

    Hi Brian,
    OAF supports the master-detail based design. You can very well implement your model. You can use 2 VO for your 2 objects and link them using a ViewLink. Check OAF Dev guide for more details.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to convert html table with all its css properties into excel , by javascript or jQuery

    hi,
    <script type="text/javascript">
    //working java script
    function CreateExcelSheet()
    var x = Table1.rows
    var xls = new ActiveXObject("Excel.Application")
    xls.Workbooks.Add
    for (i = 0; i < x.length; i++) {
    var y = x[i].cells
    for (j = 0; j < y.length; j++) {
    xls.Cells(i + 1, j + 1).Value = y[j].innerText
    } xls.visible = true
    function write_to_excel()
    str = "";
    debugger;
    var mytable = document.getElementsByTagName("table")[0];
    var rowCount = mytable.rows.length;
    var colCount = mytable.getElementsByTagName("tr")[0].getElementsByTagName("td").length;
    var ExcelApp = new ActiveXObject("Excel.Application");
    var ExcelSheet = new ActiveXObject("Excel.Sheet");
    debugger;
    ExcelSheet.Application.Visible = true;
    for (var i = 0; i < rowCount; i++)
    for (var j = 0; j < colCount; j++)
    str = mytable.getElementsByTagName("tr")[i].getElementsByTagName("td")[j].innerText;
    ExcelSheet.ActiveSheet.Cells(i + 1, j + 1).Value = str;
    //new funtion
    function ExportToExcel(mytblId) {
    debugger;
    var htmltable = document.getElementById('Table1');
    var html = htmltable.innerHTML;
    window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));
    //new funtion 2
    function write_to_excel2() {
    str = "";
    debugger;
    var mytable = document.getElementById("Table1");
    var rowCount = mytable.rows.length;
    var colCount = mytable.getElementsByTagName("tr")[0].getElementsByTagName("th").length;
    var ExcelApp = new ActiveXObject("Excel.Application");
    var ExcelSheet = new ActiveXObject("Excel.Sheet");
    //ExcelSheet.Application.Visible = true;
    for (var i = 0; i < rowCount; i++)
    for (var j = 0; j < colCount; j++)
    debugger;
    // if (i == 0) {
    // str = mytable.getElementsByTagName("tr")[i].getElementsByTagName("th")[j].innerText;
    str = mytable.getElementsByTagName("tr")[i].getElementsByTagName("td")[j].innerText;
    ExcelSheet.ActiveSheet.Cells(i + 1, j + 1).Value = str;
    ExcelSheet.autofit;
    ExcelSheet.Application.Visible = true;
    DisplayAlerts = true;
    CollectGarbage();
    //csss
    function excelExportHtml(Table1, css1)
    debugger;
    if (css1) {
    var styles = [];
    //grab all styles defined on the page
    $("style").each(function(index, domEle) {
    styles.push($(domEle).html());
    //grab all styles referenced by stylesheet links on the page
    var ajaxCalls = [];
    $("[rel=stylesheet]").each(function() {
    ajaxCalls.push($.get(this.href, '', function(data) {
    styles.push(data);
    return $.when.apply(null, ajaxCalls)
    .then(function() {
    return "<html><style type='text/css'>" + styles.join("\n") + "</style>\n" + table.outerHTML + "</html>";
    else {
    return $.when({ owcHtml: Table1.outerHTML })
    .then(function(result) {
    return "<html>" + result.owcHtml + "</html>";
    //new
    function ExportToExcel() {
    $(document).ready(function() {
    $("#btnExport").click(function(e) {
    window.open('data:application/vnd.ms-excel,' + $('#Table1').html());
    alert("jhhklhhklhklh");
    //new
    $(document).ready(function() {
    debugger;
    $("[id$=myButtonControlID]").click(function(e) {
    window.open('data:application/vnd.ms-excel,' + $('div[id$=divTableDataHolder]').html());
    e.preventDefault();
    alert("k");
    function excel()
    {debugger;
    var tableToExcel = (function() {
    var uri = 'data:application/vnd.ms-excel;base64,'
    , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
    , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
    , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
    return function(table, name) {
    if (!table.nodeType) table = document.getElementById(table)
    var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
    window.location.href = uri + base64(format(template, ctx))
    </script>
    i have tried all the above java script and jquery to convert an html table to excel, data are exporting correctly but i want that css of the table should also implent to excel thats not happening,even the property defined inside td and tr aare not implementing
    in excel

    Hi avinashk89,
    Welcome to post in MSDN forums.
    This is not the right forum for your question. Please post in
    ASP.NET forums where you could get better support.
    Thanks for your understanding.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • Can not locate driver download page.

    Can not locate driver download page. Officejet Pro 8500 A909a MS Vista Ultimate 64 Bit. When using my Linux PC to try and locate drivers for another PC, the website just keeps sending me in circles and never displays the drivers to download.  Seems l

  • How do I ping a specific port (from a specific por...

    Does anyone know of any software that will allow me to measure the bandwidth/throughput/travel time/etc of packets from a specific port to a specific port on another network? Ping gives the travel time, but doesn't allow specified ports. Iperf allows

  • Please help regarding PLSQL coding standards

    Hi, Can you please send any document for PL/SQL coding standards, Please help.. I did nt find any good resources on net regarding.. Pleease help me if any pdf regarding are exitst to my mail id [email protected] Thanks and Regards asp

  • Wireless USB adapter

    I got this USB wirelss adapter, Linksys WUSB11 Wireless USB Network Adapter Is this Solaris friendly? If not, which brand (wireless PCI/usb cards) I should try here? Thanks

  • Sharing: Uploading iMovie to Website

    Having trouble trying to put a 3 minute Quicktime movie up on a Website and getting it to run/stream continuously. At the moment it stops every few seconds waiting for buffering. I created the movie from a DVD using MPEG Streamclip 1.8, brought it in