Exporting query data to Excel - best way?

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Exporting query data to Excel - best way?

    Hi there,

    Something I've had to do a couple of times in the past but that I don't spend
    enough time to be a real whiz at is taking a query result and dumping it to raw
    text - CSV, tab-delimited, something like that. Historically, I manually wrote
    out the new file in CF with the help of chr() and so forth. Needless to say,
    'tedium' doesn't begin to describe this.

    I now have a couple clients that want to do this more often, all of them using
    Excel. In one case, they ultimately need the file in CSV format, but I'm
    wondering: is there perhaps a much easier way of doing this? Dumping a CFQUERY
    straight to XML and having Excel read that in? Some custom tag/CFC that does
    this more smoothly than I have been doing it? What's your favorite
    CFQuery-to-downloadable-file mechanism?

    Thanks!
    Samuel Knowlton
    iamsam.org

    Aquitaine Guest

  2. Similar Questions and Discussions

    1. Exporting to Excel using VB??
      Hello: I have an existing MS Access Report built that uses VB to create an Excel spreadsheet.... we are converting over to web-format (CF) and I...
    2. Exporting to Excel
      I'm new to CF, and I am wondering if there is a command or way to create a dynmaic table that depending on what fields are selected those are the...
    3. Exporting my repeat region data to MS Excel
      Hello All, I have a repeat region that shows all the information the users had put in the database, what I want is for them to be able to export...
    4. Exporting to Excel with Unicode data
      Hi I'm trying to get the datagrid to excel export working. I've used the usual code examples that are floating around and it all works fine. The...
    5. Best way to get ASP page to query Excel data (using SQL server)?
      Hi, I plan to query and process some data that resides in an Excel file on a network drive via ASP, with a SQL Server database as a go-between....
  3. #2

    Default Re: Exporting query data to Excel - best way?

    Use the code below as a starter kit.


    <cfheader name="Content-Disposition" value="inline; filename=acmesalesQ1.xls">
    <cfcontent type="application/vnd.msexcel">

    <table border="2">
    <tr><td>Month</td><td>Quantity</td><td>$ Sales</td></tr>
    <tr><td>January</td><td>80</td><td >$245</td></tr>
    <tr><td>February</td><td>100</td><td>$699</td></tr>
    <tr><td>March</td><td>230</td><td >$2036</td></tr>
    <tr><td>Total</td><td>=Sum(B2..B4)</td><td>=Sum(C2..C4)</td></tr>
    </table>

    jdeline Guest

  4. #3

    Default Re: Exporting query data to Excel - best way?

    Aha! Wonderful. So simpe. Thank you!
    Aquitaine 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