extract record from database to notepad or excel

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default extract record from database to notepad or excel

    Hi..
    Have anyone can help me how to extract data from my db to notepad or excel..? is there any tools in Dw to do this?
    samkry Guest

  2. Similar Questions and Discussions

    1. using excel as database
      :confused;I have to use excel as one of the database in order to update a table in oracle based on the data in excel. Pls is there anyone to help...
    2. How to extract multilingual to MS Excel
      How can I extract multilingual data into MS Excel application. At the moment the data extracted into Excel file is not readable. Currently using...
    3. Extract Data from Excel-files
      Hello everyone, Finally I get to use perl at work! =) I am to facing the following problem: There is a folder on a file-server in our network...
    4. Fixed Length Text Extract, Write to Excel
      Hello All, I am trying to work with the code I have to extract fields from a text file report, and write the values into excel. I am having...
    5. Is PHP able to extract data out of an Excel spreadsheet?
      The only form of database we use is an Excel database. Otherwise is it possible to import the relevant spreadsheet data into say MySQL? Perhaps it...
  3. #2

    Default Re: extract record from database to notepad or excel

    To generate an Excel page from an ASP page, simply add the following 2 lines at
    the end of your ASP coding, make sure it is the last code befor eyour HTML tag.

    <%
    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader "Content-Disposition","attachment;filename.xls"
    %>

    Originally posted by: samkry
    Hi..
    Have anyone can help me how to extract data from my db to notepad or excel..?
    is there any tools in Dw to do this?



    CarlGrint Guest

  4. #3

    Default Re: extract record from database to notepad or excel

    I'm pretty sure it should be the first thing in the page, before any
    response.write or HTML output.

    "CarlGrint" <webforumsuser@macromedia.com> wrote in message
    news:cuv4er$67u$1@forums.macromedia.com...
    > To generate an Excel page from an ASP page, simply add the following 2
    lines at
    > the end of your ASP coding, make sure it is the last code befor eyour HTML
    tag.
    >
    > <%
    > Response.ContentType = "application/vnd.ms-excel"
    > Response.AddHeader "Content-Disposition","attachment;filename.xls"
    > %>
    >
    > Originally posted by: samkry
    > Hi..
    > Have anyone can help me how to extract data from my db to notepad or
    excel..?
    > is there any tools in Dw to do this?
    >
    >
    >

    CMBergin Guest

  5. #4

    Default Re: extract record from database to notepad or excel

    Hi.
    i'm not sure how to put the scripts on my pages..
    let say if i just created new pages with only recordset or command
    storedprocedure that have sql statment , how can I call it to extract the data
    to excel?
    can i just create a link like "extract data to excel?" so whenever user click
    at this word DW will create an excel file saved to my c drive??

    samkry Guest

  6. #5

    Default Re: extract record from database to notepad or excel

    No. What you can do is create an HTML page with an appropriate header so
    that Excel 97 or later will open the file and interpret your HTML table as
    an Excel spreadsheet. You'll have to save the file yourself through the
    File->Save menu choice, or by setting the content-disposition to attachment
    (as in Carl's example) so that IE will prompt to save or open the file
    instead of just opening it.

    It's easy - add those two lines to the top of your page.

    "samkry" <webforumsuser@macromedia.com> wrote in message
    news:cuvpal$96u$1@forums.macromedia.com...
    > Hi.
    > i'm not sure how to put the scripts on my pages..
    > let say if i just created new pages with only recordset or command
    > storedprocedure that have sql statment , how can I call it to extract the
    data
    > to excel?
    > can i just create a link like "extract data to excel?" so whenever user
    click
    > at this word DW will create an excel file saved to my c drive??
    >

    CMBergin Guest

  7. #6

    Default Re: extract record from database to notepad or excel

    Guys..
    is this correct, sorry I'm still blur, so now how could i create a record set
    to call a table column in my db then extract out the data to excel sheet?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <%
    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader "Content-Disposition","attachment;filename.xls"
    %>
    </head>

    <body>
    <table width="94%">
    <tr>
    <td>Report For Database</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    <table width="94%">
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    <p>&nbsp;</p>
    </body>
    </html>


    samkry Guest

  8. #7

    Default Re: extract record from database to notepad or excel

    Create the recordset, put the data in that table, and use a repeat region.
    These are all built-in behaviors.

    The rest of the page is already set up properly. For completeness, you may
    want to change the meta tag Content-Type as well so that
    content="vnd.ms-excel" instead of "text/html; charset=iso-8859-1"

    "samkry" <webforumsuser@macromedia.com> wrote in message
    news:cvffl6$55k$1@forums.macromedia.com...
    > Guys..
    > is this correct, sorry I'm still blur, so now how could i create a record
    set
    > to call a table column in my db then extract out the data to excel sheet?
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    > <html>
    > <head>
    > <title>Untitled Document</title>
    > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    > <%
    > Response.ContentType = "application/vnd.ms-excel"
    > Response.AddHeader "Content-Disposition","attachment;filename.xls"
    > %>
    > </head>
    >
    > <body>
    > <table width="94%">
    > <tr>
    > <td>Report For Database</td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > </table>
    > <table width="94%">
    > <tr>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > </table>
    > <p>&nbsp;</p>
    > </body>
    > </html>
    >
    >

    CMBergin Guest

  9. #8

    Default Re: extract record from database to notepad or excel

    Hi..
    I manage to view all the values needed by creating the recordset, when I click
    to create a report to excel, IE just display all the data without asking me to
    save them to excel..
    below is my scripts..

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!--#include file="Connections/FFAS.asp" -->
    <%
    Dim RecordsetRpt__MMColParam
    RecordsetRpt__MMColParam = "1"
    If (Request.QueryString("VarDel") <> "") Then
    RecordsetRpt__MMColParam = Request.QueryString("VarDel")
    End If
    %>
    <%
    Dim RecordsetRpt
    Dim RecordsetRpt_numRows

    Set RecordsetRpt = Server.CreateObject("ADODB.Recordset")
    RecordsetRpt.ActiveConnection = MM_FFAS_STRING
    RecordsetRpt.Source = "SELECT m.msn,m.dpyprodnum,imei.systemserialnumber as
    imei,ieee.systemserialnumber as ieee, spck.simlockcode as spck
    ,nsck.simlockcode as nsck,nck.simlockcode as
    nck,m.palletnumber,m.deliverynumber FROM individual m inner join esn imei
    on m.msn=imei.msn inner join esn ieee on m.msn=ieee.msn inner join
    simlockcode spck on m.msn=spck.msn inner join simlockcode nsck on
    m.msn=nsck.msn inner join simlockcode nck on m.msn=nck.msn WHERE
    imei.systemserialname='imei3' and ieee.systemserialname='ieee' and
    spck.simcodename='spck' and nsck.simcodename='nsck' and nck.simcodename='nck'
    and m.Deliverynumber= '" + Replace(RecordsetRpt__MMColParam, "'", "''") + "'
    ORDER BY m.msn"
    RecordsetRpt.CursorType = 0
    RecordsetRpt.CursorLocation = 2
    RecordsetRpt.LockType = 1
    RecordsetRpt.Open()

    RecordsetRpt_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index

    Repeat1__numRows = -1
    Repeat1__index = 0
    RecordsetRpt_numRows = RecordsetRpt_numRows + Repeat1__numRows
    %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" Response.ContentType =
    "application/vnd.ms-excel"
    >
    <response.AddHeader "Content-Disposition","attachment;filename.xls"
    >
    </head>

    <body>
    <table width="94%">
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    </table>
    <p>&nbsp;</p>


    <table border="1">
    <tr>
    <td>msn</td>
    <td>dpyprodnum</td>
    <td>imei</td>
    <td>ieee</td>
    <td>spck</td>
    <td>nsck</td>
    <td>nck</td>
    <td>palletnumber</td>
    <td>deliverynumber</td>
    </tr>
    <% While ((Repeat1__numRows <> 0) AND (NOT RecordsetRpt.EOF)) %>
    <tr>
    <td><%=(RecordsetRpt.Fields.Item("msn").Value)%> </td>
    <td><%=(RecordsetRpt.Fields.Item("dpyprodnum").Val ue)%></td>
    <td><%=(RecordsetRpt.Fields.Item("imei").Value)% ></td>
    <td><%=(RecordsetRpt.Fields.Item("ieee").Value)% ></td>
    <td><%=(RecordsetRpt.Fields.Item("spck").Value)% ></td>
    <td><%=(RecordsetRpt.Fields.Item("nsck").Value)% ></td>
    <td><%=(RecordsetRpt.Fields.Item("nck").Value)%> </td>
    <td><%=(RecordsetRpt.Fields.Item("palletnumber").V alue)%></td>
    <td><%=(RecordsetRpt.Fields.Item("deliverynumber") .Value)%></td>
    </tr>
    <%
    Repeat1__index=Repeat1__index+1
    Repeat1__numRows=Repeat1__numRows-1
    RecordsetRpt.MoveNext()
    Wend
    %>
    </table>
    <p>&nbsp;</p>
    </body>
    </html>
    <%
    RecordsetRpt.Close()
    Set RecordsetRpt = Nothing
    %>
    Text

    samkry Guest

  10. #9

    Default Re: extract record from database to notepad or excel

    Because your response headers aren't in there. Why did you take them out?
    You also need to learn the difference between server-side and client-side
    code, and HTML and ASP.
    But for now, your updated page:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader "content-disposition","attachment;
    filename=desiredFilename.xls"
    %>
    <!--#include file="Connections/FFAS.asp" -->
    <%
    Dim RecordsetRpt__MMColParam
    RecordsetRpt__MMColParam = "1"
    If (Request.QueryString("VarDel") <> "") Then
    RecordsetRpt__MMColParam = Request.QueryString("VarDel")
    End If
    %>
    <%
    Dim RecordsetRpt
    Dim RecordsetRpt_numRows

    Set RecordsetRpt = Server.CreateObject("ADODB.Recordset")
    RecordsetRpt.ActiveConnection = MM_FFAS_STRING
    RecordsetRpt.Source = "SELECT m.msn,m.dpyprodnum,imei.systemserialnumber as
    imei,ieee.systemserialnumber as ieee, spck.simlockcode as spck
    ,nsck.simlockcode as nsck,nck.simlockcode as
    nck,m.palletnumber,m.deliverynumber FROM individual m inner join esn imei
    on m.msn=imei.msn inner join esn ieee on m.msn=ieee.msn inner join
    simlockcode spck on m.msn=spck.msn inner join simlockcode nsck on
    m.msn=nsck.msn inner join simlockcode nck on m.msn=nck.msn WHERE
    imei.systemserialname='imei3' and ieee.systemserialname='ieee' and
    spck.simcodename='spck' and nsck.simcodename='nsck' and
    nck.simcodename='nck'
    and m.Deliverynumber= '" + Replace(RecordsetRpt__MMColParam, "'", "''") +
    "'
    ORDER BY m.msn"
    RecordsetRpt.CursorType = 0
    RecordsetRpt.CursorLocation = 2
    RecordsetRpt.LockType = 1
    RecordsetRpt.Open()

    RecordsetRpt_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index

    Repeat1__numRows = -1
    Repeat1__index = 0
    RecordsetRpt_numRows = RecordsetRpt_numRows + Repeat1__numRows
    %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="application/vnd.ms-excel">
    </head>

    <body>
    <table border="1">
    <tr>
    <td>msn</td>
    <td>dpyprodnum</td>
    <td>imei</td>
    <td>ieee</td>
    <td>spck</td>
    <td>nsck</td>
    <td>nck</td>
    <td>palletnumber</td>
    <td>deliverynumber</td>
    </tr>
    <% While ((Repeat1__numRows <> 0) AND (NOT RecordsetRpt.EOF)) %>
    <tr>
    <td><%=(RecordsetRpt.Fields.Item("msn").Value)%> </td>
    <td><%=(RecordsetRpt.Fields.Item("dpyprodnum").Val ue)%></td>
    <td><%=(RecordsetRpt.Fields.Item("imei").Value)% ></td>
    <td><%=(RecordsetRpt.Fields.Item("ieee").Value)% ></td>
    <td><%=(RecordsetRpt.Fields.Item("spck").Value)% ></td>
    <td><%=(RecordsetRpt.Fields.Item("nsck").Value)% ></td>
    <td><%=(RecordsetRpt.Fields.Item("nck").Value)%> </td>
    <td><%=(RecordsetRpt.Fields.Item("palletnumber").V alue)%></td>
    <td><%=(RecordsetRpt.Fields.Item("deliverynumber") .Value)%></td>
    </tr>
    <%
    Repeat1__index=Repeat1__index+1
    Repeat1__numRows=Repeat1__numRows-1
    RecordsetRpt.MoveNext()
    Wend
    %>
    </table>
    </body>
    </html>
    <%
    RecordsetRpt.Close()
    Set RecordsetRpt = Nothing
    %>
    Text

    "samkry" <webforumsuser@macromedia.com> wrote in message
    news:cvhimt$hh6$1@forums.macromedia.com...
    > Hi..
    > I manage to view all the values needed by creating the recordset, when I
    click
    > to create a report to excel, IE just display all the data without asking
    me to
    > save them to excel..
    > below is my scripts..
    >
    > <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    > <!--#include file="Connections/FFAS.asp" -->
    > <%
    > Dim RecordsetRpt__MMColParam
    > RecordsetRpt__MMColParam = "1"
    > If (Request.QueryString("VarDel") <> "") Then
    > RecordsetRpt__MMColParam = Request.QueryString("VarDel")
    > End If
    > %>
    > <%
    > Dim RecordsetRpt
    > Dim RecordsetRpt_numRows
    >
    > Set RecordsetRpt = Server.CreateObject("ADODB.Recordset")
    > RecordsetRpt.ActiveConnection = MM_FFAS_STRING
    > RecordsetRpt.Source = "SELECT m.msn,m.dpyprodnum,imei.systemserialnumber
    as
    > imei,ieee.systemserialnumber as ieee, spck.simlockcode as spck
    > ,nsck.simlockcode as nsck,nck.simlockcode as
    > nck,m.palletnumber,m.deliverynumber FROM individual m inner join esn
    imei
    > on m.msn=imei.msn inner join esn ieee on m.msn=ieee.msn inner join
    > simlockcode spck on m.msn=spck.msn inner join simlockcode nsck on
    > m.msn=nsck.msn inner join simlockcode nck on m.msn=nck.msn WHERE
    > imei.systemserialname='imei3' and ieee.systemserialname='ieee' and
    > spck.simcodename='spck' and nsck.simcodename='nsck' and
    nck.simcodename='nck'
    > and m.Deliverynumber= '" + Replace(RecordsetRpt__MMColParam, "'", "''") +
    "'
    > ORDER BY m.msn"
    > RecordsetRpt.CursorType = 0
    > RecordsetRpt.CursorLocation = 2
    > RecordsetRpt.LockType = 1
    > RecordsetRpt.Open()
    >
    > RecordsetRpt_numRows = 0
    > %>
    > <%
    > Dim Repeat1__numRows
    > Dim Repeat1__index
    >
    > Repeat1__numRows = -1
    > Repeat1__index = 0
    > RecordsetRpt_numRows = RecordsetRpt_numRows + Repeat1__numRows
    > %>
    > <html>
    > <head>
    > <title>Untitled Document</title>
    > <meta http-equiv="Content-Type" Response.ContentType =
    > "application/vnd.ms-excel"
    > >
    > <response.AddHeader "Content-Disposition","attachment;filename.xls"
    > >
    > </head>
    >
    > <body>
    > <table width="94%">
    > <tr>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > </tr>
    > </table>
    > <p>&nbsp;</p>
    >
    >
    > <table border="1">
    > <tr>
    > <td>msn</td>
    > <td>dpyprodnum</td>
    > <td>imei</td>
    > <td>ieee</td>
    > <td>spck</td>
    > <td>nsck</td>
    > <td>nck</td>
    > <td>palletnumber</td>
    > <td>deliverynumber</td>
    > </tr>
    > <% While ((Repeat1__numRows <> 0) AND (NOT RecordsetRpt.EOF)) %>
    > <tr>
    > <td><%=(RecordsetRpt.Fields.Item("msn").Value)%> </td>
    > <td><%=(RecordsetRpt.Fields.Item("dpyprodnum").Val ue)%></td>
    > <td><%=(RecordsetRpt.Fields.Item("imei").Value)% ></td>
    > <td><%=(RecordsetRpt.Fields.Item("ieee").Value)% ></td>
    > <td><%=(RecordsetRpt.Fields.Item("spck").Value)% ></td>
    > <td><%=(RecordsetRpt.Fields.Item("nsck").Value)% ></td>
    > <td><%=(RecordsetRpt.Fields.Item("nck").Value)%> </td>
    > <td><%=(RecordsetRpt.Fields.Item("palletnumber").V alue)%></td>
    > <td><%=(RecordsetRpt.Fields.Item("deliverynumber") .Value)%></td>
    > </tr>
    > <%
    > Repeat1__index=Repeat1__index+1
    > Repeat1__numRows=Repeat1__numRows-1
    > RecordsetRpt.MoveNext()
    > Wend
    > %>
    > </table>
    > <p>&nbsp;</p>
    > </body>
    > </html>
    > <%
    > RecordsetRpt.Close()
    > Set RecordsetRpt = Nothing
    > %>
    > Text
    >

    CMBergin Guest

  11. #10

    Default Re: extract record from database to notepad or excel

    Thanks..
    I able to display page successfully, but one think that I need to ask is when
    I extracted the value out to excel file all numbers that lead with 0 infront
    will be truncated, as u know that with excel we can fromat the cell to text so
    it won't deleted the value, so how can aviod from my data from being truncated?

    samkry Guest

  12. #11

    Default Re: extract record from database to notepad or excel

    This is a little more difficult.
    First, try putting an apostrophe (') in front of the value to see if that
    will make Excel interpret the value as text instead of a number. That might
    solve your problem.

    If not, try casting the value from the database as text (i.e., SELECT
    CAST(MyField AS VARCHAR) AS MyField FROM ...)
    If not, post back with what database system you're using and we'll try to
    figure something out.

    "samkry" <webforumsuser@macromedia.com> wrote in message
    news:cvi91p$nul$1@forums.macromedia.com...
    > Thanks..
    > I able to display page successfully, but one think that I need to ask is
    when
    > I extracted the value out to excel file all numbers that lead with 0
    infront
    > will be truncated, as u know that with excel we can fromat the cell to
    text so
    > it won't deleted the value, so how can aviod from my data from being
    truncated?
    >

    CMBergin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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