Query results to Excel problems

I'm trying to get results from a ColdFusion query called q to go into an Excel file.
There are 2 things going wrong.
1. An Excel message comes up that says "The file you are trying to open 'stc.xls', is in a different format than specified by the file extension..."
2. character values in col1 01,02,03,... are coming over to Excel as numbers 1,2,3,...
How do I fix those 2 things ?
This is the way I'm trying to do it.
<cfsetting enablecfoutputonly="yes">
<cfcontent type="application/msexcel">
<cfheader name="Content-Disposition" value="filename=test.xls">
<cfoutput>
   <table>
      <cfloop index="ii" from="1" to="#q.recordcount#">
         <tr>
            <td>
              #q.col1[ii]#
            </td>
            <td>
              #q.col2[ii]#
            </td>
         </tr>
      </cfloop>
   </table>
</cfoutput>

Dan Bracuk wrote:
Using html table tags stopped working when MS introduced Office 2007.  Use cfspreadsheet instead.
It is not that it stopped working. Excel 2007 introduced extension hardening for increased security. So Excel warns you when the file content does not match the file extension, such as your code where cfheader claims it is an *.xls file but the content is actually html.
Users can still open the file, they will just get a warning first. The only way to prevent the warning is to a) disable the registry setting which controls the behavior OR b) ensure the content matches the file extension. For example, generating a true Excel file with cfspreadsheet or the POIUtility.  Another option is to generate an Excel xml file. IIRC, Ben Nadels blog also has some good articles on that as well.

Similar Messages

  • Http 404 error exporting query result into Excel.

    Hello. I'm getting an Http 404 The webpage cannot be found" error when trying to export any APEX application's query results into Excel (Application Express 3.2.1.00.10). This was working fine before. Nothing changed with our APEX application. I've been always using I.E. Version 7.0.5730.11 with no problems. I've reset the I.E. defaults and still the problem exists. I've downloaded Mozilla Firefox and the problem does not happen. However, I would like to know why my I.E. still gets this error? Any feedback or suggestions would greatly be appreciated. Thanks for your time.

    My EI settings are as follows:
    Tools -> Internet Options -> Security
    All Three: Internet, Local Intrarnet, and Trusted Sites ... at Custom Level have the following settings:
    Downloads:
    Automatic prompting for file downloads = Enable
    File download = Enable
    Font download = Enable
    Problem still exists.
    Thanks for the help.... any additional feedback or suggestions would greatly be appreciated. Thanks for your time.

  • How to save query result in excel file

    Hi all,
    How to save query result in excel file from sql*plus tool.
    thank you

    Do you really need an Excel file (binary) or a simple CSV?
    If you just need a CSV then search for DUMP_CSV at http://asktom.oracle.com or at this forum
    If you need formatting and/or multiple worksheets then you can use free tools like
    https://xml-spreadsheet.samplecode.oracle.com/ or https://exceldocumenttype.samplecode.oracle.com/
    Regards
    Marcus

  • Saving query results as excel

    hi,
    Is there a way to save the query results as excel programatically (some kind of utility which does the job)? we are using oracle 10g. This will be a nightly job.. so that every other day morning we have the huge excel report ready for viewing. Any help is appreciated..

    Did you think to try searching the forum? I typed in the EXACT string you used for your thread title and the first hit was ...
    Saving sql query result as excel file

  • Problems exporting query results to Excel

    Hi!
    I hope you can help me
    We have a web template that uses the class ZVIG_ART that we created in the transaction SE24, this class display some label in the query
    results, the problem is when we export this report to excel the label disappear. The numbers indicates the stock of the item and the label N/V indicates that the item is not in the  store's catalog. Another case is that we can have N/V items but with stock, for example the ITEM2 of the STORE3 with the label N/V-1piece.  How can we export this label to EXCEL?
               |  STORE1     |    STORE2   |  STORE3
    ITEM1      |  10 PIECES  |    N/V      |  20 PIECES
    ITEM2      |  11         |    20       | N/V-1PIECE
    Thanks in advanced.
    Veronica B.

    Hi Mari,
    Thanks for the reply.
    I can understand the resason for not being able to change the Posting Date. But what are the reasons for not being able to change the Document Date? What is the fiscal reason for not being able to change the Document Date? Please provide an example. Reversing the document doesn't work in this case as the SQ01 report would still include the incorrect date.
    Regards,
    Gary

  • Display Query results in excel on the Web

    Hello,
    I am trying to display data from a query in excel on the web without creating an actual file. I know that I can create a CSV file using UTL_FILE and display it but I was hoping there was a way to do it without actually creating the file. I have a procedure that looks similar to
    PROCEDURE displayAsCSV is
    cursor STUD_CURS is
    select * from students;
    BEGIN
    for STUD_REC in STUD_CURS loop
    htp.print(' " '||STUD_REC.FIRST_NAME||' " , " '||STUD_REC.LAST_NAME||' " ');
    end loop;
    END;
    Does anyone know if it is possible to display these results in excel in the browser by altering the MIME types or something similar?
    Thanks

    Check Tom's owa_sylk utility together with the appropriate mime-type.

  • How to open the TFS query results in Excel?

    Hello Guys,
    Question 1: Is there any way to export the query results from the TFS web browser?
    Question 2: Is there any way to export the query results from Team Explorer 2013?
    Here is the query results in TFS:
    How do I export this result in excel for further analysis? 
    I have also connected to Team explorer 2013 and right clicked on the query, but there is no option to open the results in Excel, see below:

    Hello,
    _Pls follow these guide lines for ensuring proper output in Microsoft Excel:
    1.First compare the fields properties and the frames properties between the reports created with wizard and the reports created manually.
    2. Do not leave any space between two adjacent objects.
    Explanation: Because any space, including a few pixels, between two adjacent objects will result in an empty cell or column in Excel output
    3.Make sure that the widths of all objects are vertically consistent.
    Explanation: If the objects are not exactly aligned vertically, that is, have inconsistent widths, it is likely to result in insertion of unwanted cells/columns in Excel.
    4. Pls. Make sure that the vertical elasticity of the frames and repeating frames is not fixed unless you are sure you have allocated enough space to accommodate all the records.
    Explanation: If you set the Vertical Elasticity property of a frame to Fixed, the output in Excel will show only as many records as could appear on the first page of the paper output. Since Excel does not have a page concept, it is not able to overflow the remaining rows to the next page.
    5. For reliable formatting of spreadsheet output, enclose the whole layout area in a frame.
    Explanation: This action prevents the possibility of parallel objects displaying in different vertical positions, one following the other.
    Hope this helps.
    Regards,
    Alex

  • Export query results to excel from forms

    Are there any ways to export query results to MS Excel format files from a form.
    Thanks.

    Here's my working code out of one of my forms that does this:
    PROCEDURE export_transactions_to_excel IS
    -- Declare the ole objects
    application ole2.obj_type;
    workbooks ole2.obj_type;
    workbook ole2.obj_type;
    worksheets ole2.obj_Type;
    worksheet ole2.obj_type;
    cell ole2.obj_type;
    -- my variables
    rowCounter Number := 1;
    local_cursor_Record number := :System.Cursor_Record;
    old_cursor_Style varchar2(100);
    errors_occurred boolean := false;
    Ole_Error Exception;
    pragma exception_init( Ole_Error, -305500 );
    my_alert_id ALERT;
    alert_response NUMBER;
    procedure place_value_in_cell( rownum_in in number
    , colnum_in in number
    , value_in in varchar2 )
    is
    -- Declare handles to OLE argument lists
    args ole2.list_Type;
    begin
    args := ole2.create_arglist;
    ole2.add_arg(args, rownum_in); /* row number */
    ole2.add_arg(args, colnum_in); /* column number */
    -- the next line is for excel97
    -- cell := ole2.invoke_obj( worksheet, 'Cells', args );
    cell := ole2.get_obj_property( worksheet, 'Cells', args );
    ole2.Destroy_arglist( args );
    ole2.set_property( cell, 'Value', value_in );
    ole2.release_obj (cell);
    end place_value_in_cell;
    procedure SaveSpreadsheet
    is
    args ole2.List_Type;
    vDateStamp varchar2(20);
    begin
    vDateStamp := to_char(sysdate,'mmddyyyy') &#0124; &#0124; '_' &#0124; &#0124; to_char(sysdate,'hh24miss');
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args, 'C:\PAPRETCC_' &#0124; &#0124; vDateStamp &#0124; &#0124; '.XLS');
    OLE2.INVOKE(worksheet, 'SaveAs', args);
    OLE2.DESTROY_ARGLIST(args);
    --args := Ole2.Create_ARgList;
    ole2.invoke( application, 'Quit' );
    end SaveSpreadSheet;
    procedure Open_EXCEL_Workbook is
    Begin
    application := ole2.create_obj('Excel.Application');
    --ole2.set_property( application, 'Visible', 'True' );
    -- Return object handle to the Workbooks collection
    workbooks := ole2.get_obj_property( application, 'Workbooks' ); -- invoke_obj w/ excel 97
    -- Add a new Workbook object to the Workbooks collection
    workbook := ole2.invoke_obj( workbooks, 'Add' );
    -- return object handle to the Worksheets collection for the
    -- Workbook
    worksheets := ole2.get_obj_property( workbook, 'Worksheets' ); -- invoke_obj w/ Excel97
    -- Add a new Worksheet to the Worksheets collection
    worksheet := ole2.invoke_obj( worksheets, 'Add');
    end open_EXCEL_workbook;
    PROCEDURE Write_Column_Headers IS
    BEGIN
    place_value_in_cell(rowCounter,1, 'Payer Name');
    place_Value_in_cell(rowCounter,2, 'Payer Address');
    place_value_in_cell(rowCounter,3, 'SSN');
    place_value_in_cell(rowCounter,4, 'Account');
    place_value_in_cell(rowCounter,5, 'Refund Receipt');
    place_value_in_cell(rowCounter,6, 'Pretax Allocation');
    place_value_in_cell(rowCounter,7, 'Tax Allocation');
    place_value_in_cell(rowCounter,8, 'Total Amount');
    place_value_in_cell(rowCounter,9, 'Orig Receipt');
    place_value_in_cell(rowCounter,10,'Orig Date');
    place_value_in_cell(rowCounter,11,'TR Number');
    place_value_in_Cell(rowCounter,12,'Date');
    place_Value_in_cell(rowCounter,13,'Status');
    place_value_in_cell(rowCounter,14,'Vt Number');
    rowCounter := rowCounter + 1;
    END Write_Column_Headers;
    PROCEDURE Export_The_Data IS
    original_receipt number;
    original_date DATE;
    original_transmittal_number number;
    BEGIN
    -- Return object handle to cell A1 on the Worksheet
    Go_block('Transactions');
    First_Record;
    LOOP
    IF alert_response = ALERT_BUTTON2 or
    (alert_response = ALERT_BUTTON1 and nvl(:transactions.rg_approval,'N') <> 'N' )
    -- :system.record_status = 'CHANGED')
    then
    place_value_in_cell( rowCounter, 1, :TRANSACTIONS.NDB_PAYEE_NAME );
    place_value_in_cell( rowCounter, 2, nvl(:TRANSACTIONS.NDB_PAYEE_ADDRESS,'unknown') );
    place_value_in_cell( rowCounter, 3, nvl(:TRANSACTIONS.NDB_SSN,'unknown') );
    place_value_in_cell( rowCounter, 4, :transactions.NDB_DESCRIPTION );
    place_value_in_cell( rowCounter, 5, to_char(:Transactions.transaction_group_EID) );
    place_Value_in_cell( rowCounter, 6, to_char(:transactions.ndb_pretax_amount) ); -- chg
    place_ value_in_Cell( rowCounter, 7, to_char(:transactions.ndb_tax_amount) );
    place_value_in_cell( rowCounter, 8, to_char(:transactions.amount_including_taxes) );
    original_receipt := revenue_pkg.original_receipt_number(
    :transactions.transaction_group_eid,
    :transactions.allocation_eid,
    :transactions.allocation_table );
    original_date := revenue_pkg.original_receipt_date(
    :transactions.transaction_group_eid,
    :transactions.allocation_eid,
    :transactions.allocation_table );
    original_transmittal_number := revenue_pkg.transmittal_number_for_receipt(original_receipt);
    place_value_in_cell( rowCounter, 9, nvl(to_char(original_receipt),'unknown') );
    place_value_in_cell( rowCounter, 10, nvl(to_char(original_date,'mm/dd/yyyy hh24:mi:ss'),'unknown') );
    place_value_in_cell( rowCounter, 11, nvl(to_char(original_transmittal_number),'unknown') );
    -- COMPTROLLER COLUMNS
    IF ( alert_response = ALERT_BUTTON1 and nvl(:transactions.rg_approval,'N') <> 'N' )
    THEN
    place_value_in_cell( rowCounter, 12, to_Char(sysdate,'mm/dd/yyyy') );
    place_value_in_cell( rowCounter, 13, nvl(:transactions.rg_approval,'N') );
    place_value_in_cell( rowCounter, 14, nvl(to_char(:location.vt_number),'NULL') );
    END IF;
    End If;
    exit when :SYSTEM.LAST_RECORD = 'TRUE';
    NEXT_RECORD;
    rowCounter := rowCounter + 1;
    END LOOP;
    END Export_The_Data;
    /* ----------------------------------- main procedure --------------------------------------*/
    BEGIN
    Begin
    my_alert_id := Find_Alert('THREE_BUTTON_ALERT');
    IF NOT ID_NULL( my_alert_id ) then
    alert_Response := SHOW_ALERT( my_alert_id );
    If (alert_response = ALERT_BUTTON1) OR
    (alert_response = ALERT_BUTTON2) then
    old_Cursor_style := get_application_property( CURSOR_STYLE );
    set_application_property( CURSOR_STYLE, 'BUSY' );
    Open_EXCEL_WorkBook;
    Write_Column_Headers;
    Export_The_Data;
    Else
    Raise Form_Trigger_Failure;
    End If;
    Else
    Raise Form_Trigger_Failure;
    End If;
    exception
    when Form_Trigger_Failure then
    RAISE;
    when Ole_Error then
    AlertSend( 'There was an error exporting the data to Microsoft Excel (receipt# ' &#0124; &#0124;
    to_Char(:transactions.transaction_Group_eid) &#0124; &#0124; ')', false );
    errors_occurred := TRUE;
    when others then
    AlertSend( SQLERRM, false );
    errors_occurred := TRUE;
    End;
    Ideally, I'd like to call SaveSpreadsheet in Export_The_Data, and just ExitExcel here,
    but it prompts for whether to save the changes and I don't know how to get around that
    right now. SO, we just save and exit, regardless.
    SaveSpreadSheet;
    -- Release the OLE objects
    ole2.release_obj (worksheet);
    ole2.release_obj (worksheets);
    ole2.release_obj (workbook);
    ole2.release_obj (workbooks);
    ole2.release_obj (application);
    IF NOT errors_occurred then -- stay on the record that caused the error
    Go_Record( local_cursor_Record );
    End If;
    Set_Application_Property ( CURSOR_STYLE, old_cursor_style );
    EXCEPTION
    When Form_Trigger_Failure then
    null;
    When Others then
    AlertSend( SQLERRM );
    END export_transactions_to_excel;

  • Export result of ssas query result to excel file

    Hi All,
    I have browsed a SSAS cube. I want to export result of SSAS cube into excel file.
    Kindly give your input.
    Thanks,
    Vivek singh

    Hi,
    I do not know whether there is a direct solution but there is an indirect way of doing it. I always follow this method if I ever want to get MDX results into Excel.
    1 - Install the DAX Studio (I know you want MDX results, so do not get confused by looking at the word DAX. Continue reading). You can download it from the following location.
    http://www.sqlbi.com/tools/dax-studio/
    2 - Once you install DAX Studio, Go to the Add-Ins ribbon. Click on DAX Studio. 
    3 - There is an option "Tabular Server" and there is a drop-down list where you can enter the SSAS (MD CUBE Server) server name. Enter the server name manually. If you have multiple SSAS Databases and if you are interested in a specific SSAS database
    enter "Initial Catalog=Your SSAS Database Name" in Additional Options section and Click Connect. You can successfully connect to the SSAS Server now.
    Here are the details described so far in pictorial representation.
    4 - Enter your MDX manually and execute the code via DAX studio and you will get your results right-away in Excel.
    Now, isn't that an elegant way of getting MDX results into Excel :) ? Besides Excel's Pivot Table option, I do not know whether there are any alternate solutions to this but wait for other Pros' comments as well.
     Best regards...
    Chandima Lakmal Fonseka

  • Select query results into excel file

    Hi,
    I want to put the results of a select query in an csv file(tab separated columns). I dont want to spool command for this . Is there any other method to do this.
    Thanks

    To get data from oracle to excel to use odbc driver to achive this.

  • Mapping query result to excel sheet

    Hi Experts,
    i have a requirement where in i need to map the result into particular cellls of the excel sheet, because the excel sheet acts as front end which has graphs and by just putting the result in particular cells of excel the graph is automatically generated, so is there any way where i can map the result cells into particulat cells in excel?
    Thank you.

    Hi Shetty,
    You might have stopped reading this thread since you have the answer you need for now.  From experience, let me tell you what might happen next.
    If the query definition is ever changed ... say, a new characteristic is added because a different user has a slightly different need ... the result table will move down by a few rows and your equation no longer works.
    If you think this might happen, let me tell you a very easy way to get around it.
    1.  Name the range(s) you will use.  If the first result is in cell B31 on Sheet1, then go to cell B31 on Sheet1 and Select Insert>>Name>>Define.  Call it something you will remember, like "LastMonthSales" (no spaces, but underline is OK)
    2. use the range name in your formula.  This happens automatically, in fact.  If you press = then click on cell B31, Excel will automatically use the range name instead of the range address.  Excel LIKES names.
    3. now, go to the Visual Basic Editor (Tools >> Macro >> Visual Basic Editor; or, Alt+F11).  In your workbook, there should be a subroutine as follows:
    Sub SAPBEXonRefresh(queryID As String, resultArea As Range)
    If you do not find it, add it.  This probably also means that you are using Excel 2002 or later and have not set your Macro security to "trust access to Visual Basic Project"; so, change that security setting (Tools >> Options >> Security >> Macro Settings).
    The visual basic code is very simple.  For each result that you need to map you will want one line of code like this one:
    resultArea.Cells(4, 2).Name = "LastMonthSales"
    The Cells(4, 2) are counted from the top left of the result table.  So, in this case if B31 = Cells(4,2), then the top left of my result table must have been in cell A28 in Excel.
    This subroutine will be run automatically every time that the query is refreshed.  So, if the result table moves, the names will move with it.  One less thing to worry about.
    If you do not think you need to do this today, don't!  No sense in doing work that is not necessary.  But, save this.  I suspect that some day you will need it.
    - Pete

  • About exporting query result to excel

    Hi all,
    I take the report result to an excel file and at this point I am being asked for my user name and password of BW login, repeatedly for many times, based on the amount of data it contains. Its quite irritating, as i need to fill that each time, it asks for that. So kindly suggest me, how to deal with this.
    Regards,
    Naveen.A

    Hi Naveen,
    Not sure that understood what you exactly meant. But will try to help. When you execute query in BEx you can save a workbook detaching it from a server. In this case all reporting information will be kept without further updating from a server. The client will just open the wb and see all information. Certainly, he will not be able to make drilldowns. But for this you save your wb as a view with all drildowns already done.
    Best regards,
    Eugene

  • Procedure to write Oracle Query Result to Excel file?

    Hi All,
    I have a requirement to write a procedure which will write the result of a Query (select statement) to a Excel file.
    I use a third party tool to do so but it fails when the query fetches more than 65000 records!
    Can someone suggest me a procedure ( may be written in PL/SQL ) which can be used to achieve this task?
    If there is a procedure available readily, can you please share it with me?
    Thanks in advance
    Himanshu Dabir

    There is a ready procedure (actually PL/SQL blocks by Tom Kyte) available at
    http://www.quest-pipelines.com/newsletter-v5/0704_C.htm
    but it also suffers from Microsofts limitation of 65536 rows per sheet.

  • Query Result with pagination problem

    I have a region that has a search field with a "Go" button which runs a report based on a SQL Query(PL/SQL function body returning SQL query). Works great and displays the default of 15 rows with a pagination scheme of "Row Ranges X to Y of Z(with pagination)". The problem is that when I click on the "Next rows ... " link the screen goes blank and I have to click on the "Go" button before it displays the next 15 rows. How do I get around this problem of having to click on the "Go" button?
    thanks
    John

    Hi John,
    I am also facing the same problem. Any solution has been found out by you.
    If so, please give it in the forum know.
    Thanks in advance
    kavitha l

  • Saving sql query result as excel file in different spreadsheets

    Hi,
    I have exported the output of sql into excel sheet as follow:
    SET LINESIZE 80
    SET PAGESIZE 0
    SET FEEDBACK OFF
    SET SPOOL ON
    SET TERMOUT OFF
    SPOOL current_employees.csv
    SELECT '"ID","Sales Amount","Region Id","Sales Date"' FROM dual;
    set colsep ,
    SELECT * FROM sales;
    SPOOL OFF
    But my question is how can I export SQL output in multiple excel spredsheets?
    Is there anything by which I can switch my spreadsheets through the above SQL script?
    Regards,
    Ashish

    Hi,
    I have exported the output of sql into excel sheet as follow:
    SET LINESIZE 80
    SET PAGESIZE 0
    SET FEEDBACK OFF
    SET SPOOL ON
    SET TERMOUT OFF
    SPOOL current_employees.csv
    SELECT '"ID","Sales Amount","Region Id","Sales Date"' FROM dual;
    set colsep ,
    SELECT * FROM sales;
    SPOOL OFF
    But my question is how can I export SQL output in multiple excel spredsheets?
    Is there anything by which I can switch my spreadsheets through the above SQL script?
    Regards,
    Ashish

Maybe you are looking for

  • JSF webapp works with Java 1.4, but not Java EE 5

    Hello I am having a really weird problem with internationalizing my JavaServer Faces web application. I am using Netbeans 6.0, Tomcat 6.0.10, JSF 1.2, and JTSL 1.1.... If I use Java 1.4 to run the webapp, everything works fine! If I use Java EE 5 the

  • Creating a Photoshop Brush - Problem

    I'm trying to create a brush from a simple rectangular shape.  The steps I do are simple, create a solid rectangular vector shape, then rasterize the layer.  This is where it goes sour, after creating the shape and rasterizing it I select the maraque

  • Populating a PDF file with Database Field values - URGENT PLEASE REPLY

    I have a requirement where in I hae PDF files as templates. The data for these templates is the database. Example : a.pdf Name : Database table : name varchar(20) What I want to do is read this PDF template and populate the Name with the value in the

  • How to see the alerts

    Hi, in OEM 9.2.0 , how to see the alerts ( or the errors indicated in alertlog) and the problems and errors if any on the databases ? Many thanks.

  • ICal Shared Not Appearing on iOS Devices But Do In Macs' iCals

    I am running Mountain Lion, but this issue was also happening in Lion. As a former Apple Specialist who specialized in iCloud, I've stumped myself and several AppleCare reps. They have forwarded this on to the engineers.  I have three calendars that