ColdFusion in excel

Hello!

I am trying to take the output of a CFQUERY and place it in an excel file.

After doing some research, I wrote this code:


< CFQUERY NAME = "myQuery" DATASOURCE = "site" >
SELECT Site, date of DF_Error WHERE the Site AS 'PERDQ % '.
< / CFQUERY >
< cfsetting enablecfoutputonly = "Yes" >

< cfset TabChar = Chr (9) >
< cfset NewLine = Chr (13) & Chr (10) >

< cfcontent type = "application/msexcel" >

< name cfheader = "Content-Disposition" value = "filename = output.xls" >

< cfloop query = "myQuery" >
< cfoutput > #Site ##Date ##ServiceName # NewLine # < / cfoutput >
< / cfloop >


When I access the page in Internet Explorer, he tries to save the file as the cfm (exceltest.cfm) file and gives me an error that says: it cannot download the file.

If anyone can help?

Thank you!




Try to put your header above the content tag tag. Add the reset = "Yes".
parameter for the tag content. You want to be very careful about the extra
the content that is generated when you try to send files to other formats then
HTML. They do not handle extra characters, whitespace or otherwise, to title
forgivingly in HTML was designed to do.

Tags: ColdFusion

Similar Questions

  • Import excel should allow space in a column during the use of media: the value class coldfusion.sql.QueryColumn can not be converted to a date

    I followed the pretty good learncfinaweek and can see no error in my code.   Here is the error, that should solve and the page with the code.  Any help is appreciated.  This should be quite simply like this: < cfset blogPost.dateposted = importData ["posted Date"] / >, which allows the column in excel with a space between words.

    Good: dateposted - the coldfusion.sql.QueryColumn class value cannot be converted to a date.

    Root cause: org.hibernate.HibernateException: property: dateposted - the coldfusion.sql.QueryColumn class value cannot be converted to a date



    "< cfimport taglib ="... /... "/ customTags" prefix = "ct" / >

    < ct:securityCheck redirectPage = "#cgi.script_name #" / >

    < name = "cfparam form.submitted" default = "0" / > "

    "< name =" cfparam form.importFile"default =" "/ >

    < cfif form.submitted >

    <! - Download file - >

    < cffile action = "upload" destination = "#getTempDirectory ()" # "filefield ="importFile"nameconflict ="makeunique"/ >"

    <!--> reading spreadsheet

    "< cfspreadsheet action = 'read' src="#cffile.serverDirectory#/#cffile.serverfile# ' query = headerrow "importData" = "1" excludeheaderrow = "true" / >

    <!--> Import data

    < cfloop query = "importData" >

    < cfset blogPost = entityNew ('blogPost') / >

    < cfset blogPost.title = importData.title / >

    < cfset blogPost.summary = importData.summary / >

    < cfset blogPost.body = importData.body / >

    < cfset blogPost.dateposted = importData ["posted Date"] / >

    < cfset EntitySave (blogPost) / >

    < / cfloop >

    < cfset ormFlush() / >

    < cflocation url = "listblogpost.cfm? message = #urlencodedformat ('Blog Posts Imported Successfully')" # "addtoken ="false"/ >"

    < / cfif >

    < cfoutput >

    < section ct:layout = "Summary" >

    < section = 'blog' active 'post' = ct:navigation / >

    < div class = "span10" >

    The Blog posts to download < h2 > < / h2 >

    < form class = "form-horizontal" action = "" #cgi.script_name # "method ="post"enctype =" multipart/form-data">"

    < div class = "control group" >

    < class label = 'label control' for 'importFile' = > import file < / label >

    < div class = "orders" >

    < input type = "file" id = "importFile" name = "importFile" value = "#form.importFile #" >

    < / div >

    < / div >

    < div class = "control group" >

    < div class = "orders" >

    < button type = 'submit' class = "btn, btn-primary" > download < / button >

    < / div >

    < / div >

    < input type = "hidden" name = "subject" value = "1" / >

    < / make >

    < / div >

    < / ct:layout >

    < / cfoutput >


    DavidSCarlisle55 wrote:

    I changed the date to 'YYYY-MM-DD' in the xls file by changing to the UK format within excel.

    It is still giving an error.  ?

    Odd. Then there can be only one solution to the riddle: what you read is a column name, and not the date value stored in the column.

    See what happens when you replace this line by

    or, perhaps better,.

  • coldfusion excel file reading

    Hello world
    I am downloading a file my cfm page excel.
    I want to read these values excel file and update the database.
    I'll be help full if you like how to parse excel value.

    ColdFusion is installed on sun solaris Server

    Thank you

    Ok.
    Thank you!

    If you answer this question, please mark as well.

    If there are no more questions, please start a new thread.

    Thank you
    -MikeR

  • ColdFusion does not recognize the CSV files

    I have a local version of ColdFusion developer 10 on my local machine.

    I use ColdFusion to create a CSV file and save it on the server and create a link by using the following code.

    Browsers open the CSV file in a text file and I use link right click to save target, my Windows Explorer save a html file.

    It works on the other server, using the same code.

    I want to know are there any which configuration to set ColdFusion recognize the format of CSV file when saving the target and he lets browsers know how to use Excel to open CSV files.

    Your information and help is much appreciated,

    Kind regards

    Mouses,

    < Cfset thisPath = ExpandPath("*.*") >

    < cfset f_dir = GetDirectoryFromPath (thisPath) >

    < cfset what = "#dateformat (now (), 'mmddyy') ##timeformat (now (), 'hhmm') # .csv" >

    < cffile action = "WRITE" line = "" f_dir # # how # ""

    output = "MtField1, MyField2" addnewline = "Yes" >

    < cfloop query = "#myQuery #" >

    < cffile action = "APPEND" file = "" f_dir # # how # ""

    output = "Field1 # #, #Field2 # ' addnewline ="Yes">

    < / cfloop >

    < cfset lelien = "MyServer/report /" & what > »»

    < cfoutput > < a href = "#theLink #" > here is the file < /a > < / cfoutput >

    < br >

    There are several different themes play. I have them separate to make the code more manageable and scalable.

    Using your code, I've implemented the following quick test. It uses the embedded, cfartgallery data source, you have also.

    I placed the 3 files in the same directory. But this is usually unnecessary because you can pass the path of the directory as a variable.

    fileWrter.cfm

    Select the city, email

    artists

    Here is the file

    fileDownload.cfm

    You must first create the download file.

    File.CFC

  • Problem with cfspreadsheet and excel files

    Hello

    I have a request from a client to generate a worksheet excel from a query. I have the query expel the fields and I can generate the Excel without a hitch. The problem comes when the customer takes excel file and then tries to handle it. The majority of the distress comes from fields that must be marked as currency or dates. I am, with a few combat capable of generating a 'real' date field Before this Excel was not correctly sort dates.

    I was able to call an excel formula using this:

    < cfset SpreadsheetSetCellFormula (, "DATEVALUE (#Chr (34) #Replacement_ETD ##Chr (34) #)", therow, 9) >

    Date value Force Excel to recognize him as a real date field. However, this fails when this file is manipulated by excel. The next problem is the currency field. I can't get excel to recognize it as a currency. It's always personal. When it is set, the SUM function will not work in excel. You can add the fields individually as A1 + B1 + C1 = TOTAL. This will not help when there are 200 lines.

    I was able to get a suggestion from an other CF developer who has had a similar situation. He generated the first with the appropriate items excel file and set the columns to their fields such as date and currency, etc.

    The next step would be to fill the rank by rank, and they must be properly formatted.

    Code:

    ("< cfset expandPath("./reports/arrivals.xlsx = filename ") >

    < cfspreadsheet action = "read" src = "#filename #" name = "s" >

    < cfset therow = 0 >

    < cfoutput query = "myExcel" StartRowOptional = "1" >

    < cfset therow = myExcel.currentrow + 1 >

    < cfset SpreadsheetSetCellValue (holders, s, therow, 1) >

    < cfset SpreadsheetSetCellValue (s, Section, therow, 2) >

    < cfset SpreadsheetSetCellValue (s, Position_Number, therow, 3) >

    < cfset SpreadsheetSetCellValue (s, Position_Title, therow, 4) >

    < cfset SpreadsheetSetCellValue (s, Incumbent_Emplyment_Type, therow, 5) >

    < cfset SpreadsheetSetCellValue (s, Incumbent_ETD, therow, 6) >

    < cfset SpreadsheetSetCellValue (s, Tour_Comments, therow, 7) >

    < cfset SpreadsheetSetCellValue (s, replacement, therow, 8) >

    < cfset SpreadsheetSetCellValue (s, Replacement_ETA, therow, 9) >

    < / cfoutput >

    < name cfheader = "content-disposition" value = "attachment; filename = Departures_ (#DateFormat (now (), 'MMDDYY') #) .xls ">"

    < cfcontent type = "application/msexcel" variable = "#spreadsheetReadBinary (s)" # "reset ="true">"

    The data in the cells has already been formatted properly. When this file is generated and sent to the user columns are not formatted as expected.

    Does anyone know if this method will work or have a better suggestion on CF getting to generate a suitable date and currency field to Excel for acknowledge?

    Adobe ColdFusion running on RHEL 5 v10

    Thank you

    For some reason, you need to format it twice - once before the data is inserted and one after.

    This is especially true if you have data values that are integers.  These, even if you format cell advance to be 'Text', always align to the right, as do the integers.  However, if you reapply the formatting after inserting the data, then it must be formatted correctly.

    HTH,

    ^_^

    PS. Thank YOU for taking the time to code for spreadsheetsetcellvalue (CF)!  Too many people become lazy and chuck just a query to an object tag cfspreadsheet.

  • If you use CFHEADER and CFCONTENT to disseminate an Excel file, Javascript still works?

    Hello, all,.

    I use a hidden iFrame which loads a page using CFHEADER and CFCONTENT to disseminate an Excel of a form submission.  I'm _trying_ to use JavaScript to change the value of the button element that sends the form to the parent page.

    I see no success.  JavaScript still works when a page using CFHEADER and CFCONTENT?

    I can't even a simple JS alert() to work.

    V/r,

    ^_^

    I don't expect Javascript to run when you use,

    These tags Coldfusion binary content, i.e. sending code Excel, result to the browser.

  • 10 ColdFusion does not seem to use all 8 cores (2 physical cpu on physical hardware)

    Our Standard 10 Coldfusion server is not higher than 25% never dope.

    I have a time hard to believe that we write this incredibly excellent code to have more than 100 users never do our server over 25% spike...

    How can I check to see how many CPU is using ColdFusion or the number of processors it will use?

    Thank you!

    One of the ways of loading CF with use is to use Apache JMeter. Reference:
    https://JMeter.Apache.org/

    Briefly. In Jmeter to Test Plan, add Threads (users) then thread group.
    In the Group of threads add Sampler HTTP Request.
    Inside the Group of threads increases the number of Threads 1 to 30 of say.
    Change the HTTP request to include the server name or IP of FC
    Port 80 or 8500 for example function built in CF webserver or IIS / Apache.
    Path to the CFM file your going to use it.

    Press the Stop Go.

    HTH, Carl M.

  • Display data in Excel

    Hello

    I have an excel sheet, I want to display the data in this great sheet after reading it.

    Anyway is to do.

    With the help of coldfusion 9, Apache

    Well, everyone who cares about what I'm up to is out of the office, then might as well have a bash at it. As expected, it was also easy:


       

    And I get an Excel-stylee grid display my query data. Let us know what the issue is, and I'll have a look if I have nothing better to do, which is likely enough for the next three hours.

  • &lt; cfspreadsheet &gt; and "...". "maximum number of fonts has been exceeded" error in Excel 2007

    A client and I both live the same error message when you open a spreadsheet generated by ColdFusion version 9.0.0 (deployment of Windows). The generated workbook is relatively complex, with a summary tab and about 25 other tabs.

    Here is the exact error that opens in Excel 2003 and 2007:

    Some text formatting may have changed in this file, because the maximum number of fonts has been exceeded. It can help to close other documents and try again.

    This only happens when the amount of data stored in the document is larger (but I can't tell you exactly how big the document must do in order to start to trigger this error). I'm no formatting with fonts, which explains why this error is confusing for me. There are some columns I'm formatting in different data formats in each tab, things like this:

    <cffunction name="formatEventSheet" hint="Formats a given row in a spreadsheet and returns the spreadsheet object.">
        <cfargument name="spreadsheet" hint="Spreadsheet object to manipulate. Active sheet must be set to sheet to modify.">
     
        <cfset var loc = StructNew()>
     
        <!--- Currency formatting --->
        <cfset loc.currencyFormat = StructNew()>
        <cfset loc.currencyFormat.dataFormat = "($##,####0.00);($##,####0.00)">
        <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 5)>
     
        <cfreturn arguments.spreadsheet>
     
    </cffunction>
    


    <cffunction name="formatEventSummarySheet" hint="Formats a given row in a spreadsheet and returns the spreadsheet object.">
        <cfargument name="spreadsheet" hint="Spreadsheet object to reference. Active sheet must be set to sheet to modify.">
     
        <cfset var loc = StructNew()>
     
        <!--- Currency formatting --->
        <cfset loc.currencyFormat = StructNew()>
        <cfset loc.currencyFormat.dataFormat = "($##,####0.00);($##,####0.00)">
        <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 4)>
        <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 6)>
        <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 8)>
        <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 10)>
        <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 12)>
        <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 14)>
        <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 16)>
     
        <cfreturn arguments.spreadsheet>
     
    </cffunction>
    

    I can post some more code if need be (there are lots of it), but I was wondering if anyone has run across this in general and they did to remedy.

    Post edited by: Chris Peters - added syntax highlighting.

    Here is some information from a post on experts-exchange website. It seems that this could be applicable in your case...

    This error is generated when you have maxed out the internal formatting tables.

    Here are a few notes on the reduction of the use of the entries in the table formatting...

    A common misconception is that at some point in formatting any range of contiguous cells results in smaller workbooks. It is, for the most part, is not true. The only time where excel keeps the size of the workbook is when a column of cells is formatted to a starting cell to the bottom of the worksheet. The starting cell can be on a line, but the last cell must be on the last line of the spreadsheet. Layout of several contiguous columns at the bottom of the worksheet gives the same result as formatting each column individually.

    Note that when formatting of the horizontal borders in a column, do not set the bottom as border doing so will require as much file size as if every cell in the column have been formatted separately. Set inside horizontal border only.

    A quick test shows this behavior. Create two new workbooks. In the first, select the A2:A65536 cells, set the background color and save. In the second, select the A2:A65535 cells, set the background color and save. Using Windows File Explorer, look at the size of the files of the two workbooks. Note that the first workbook is approximately 12 KB in size, while the second is more than 2 MB.

    Formatting columns of cells in this way has another advantage: the used range is unaffected. In other words, if the formatting of the cells A2:A65535 the used range is set to A2:A65525. However, if the A2:A65536 cells are formatted, the used range is affected. Note that this is not true in line or horizontal direction. In other words, a line in the format of the column at the right IV reset the range used to include column IV. Also, note that this problem has been corrected in Excel 2003 and lines behave like columns in 2003 regarding the used range.

    Another interesting aspect of formatting of columns to the bottom of the worksheet is that the completed workbook file size advantage is not compromised by reformatting the individual cells within the larger range. For example, if A2:A65536 of cells are formatted as cell A1000 is then formatted another way, the size of the workbook file continues to be small.  This is true even if cell A65536 got rid of all formatting. Note that the unformatted cells consume space because they are exceptions to the first formatting and so services provided by the formatting at the end of the worksheet are eroded as more and more cells are positioned to other formats or erased formats.

  • export data to Word with Coldfusion

    Saw the link to

    http://www.irt.org/articles/js154/index.htm which explains how to...

    But my need is a little more than what is shown.

    I have to run a query and results on the basis of this to decide what should be a title of rank, and then display its value. Something like

    < name cfquery = "getDepartments" datasource = "#Application.ds #" >
    SELECT *.
    Ministries
    WHERE deptID = ' #form_data.deptID # '.
    < / cfquery >

    then

    < table width = "100%" border = "1" rules = "all" cellpadding = "5px" cellspacing = "0px" style = "width: 100%;" do-family: Arial, Helvetica, without serif. do-size: 12px; ">
    < b >
    < style td = "do-family: Arial;" do-size: 12px; "> < b >

    < cfif getDepartments.DEPT_TYPE is "AP" >
    Corporate
    < cfelse >
    Retail
    < / cfif >
    : < /b >
    < br >

    It works not with the method indicated on the link http://www.irt.org/articles/js154/index.htm

    How can I get what I want?

    Any advice would be welcome.

    Well, the two formats are completely different. I don't think that you can mix the two. So, either you try to create a rtf or html file.

    Most of the versions of MS Word are able to interpret/display html. Unless you specifically need a rtf file, so it is easier to generate just plain html. Then use cfheader and cfcontent to indicate that the document must be opened with MS Word. There is an example to Excel at the bottom of this page. But the same concept applies to Word files. Just use the correct mime type and name.

    http://livedocs.Adobe.com/ColdFusion/8/htmldocs/help.HTML?content=Tags_c_11.html

  • Output to several tabs in Excel

    IM using < type CFCONTENT = "application / vnd.ms - excel" > in my code and I need the results of a number of queries each in a separate tab

    in Excel. How do I do that?

    doesn't have the ability to do multiple tabs in an Excel output.

    If you want this level of control, you need to be spending CF9 new excel integration technology.

    87. html http://help.Adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec17cba-7F

    OR

    For the former ColdFusion servers, dive into the minion of Java and use POI integration technology.

    cel - Files.htm http://www.bennadel.com/blog/474-ColdFusion-component-wrapper-for-POI-to-read-and-write-ex

  • Excel formula

    Help!
    I need to create a spreadsheet from coldfusion, but allow the user to change the formula
    I was able to make the problem I have is how to add the % sign in the cell with errors

    As Boolean = 1 / / As Boolean toread
    lastCell = 10 / / last cell to read
    < cfoutput >
    = Round(a#firstCell#/a#lastCell#%,2)
    < / cfoutput >
    This will give me something like
    44.50, but I required in order to demonstrate that 44.50%
    I try to get information from excel but I am havig some problem to find the answer

    Thank you

    bad place to posted

  • Create the Excel ODBC socket connection

    Hello, helpful people!

    I installed CF8 without documentation. This caused the problem known to not do an install complete ODBC drivers. In fact, I was doing very well (I could, for some reason, use MySQL driver doesn't have a problem) until I suddenly wanted an Excel driver.

    I searched online, found my answer and started to follow the instructions:
    http://www.Adobe.com/go/kb402637

    Unfortunately, I can't follow instructions #6, "Run instODBC.cfm in a browser using the location you have stored to." each time I run it, I get an error "current user is not authorized to invoke this method" - even when I'm logged on as administrator.

    I tried to move the installODBC.cfm file to a few places (including in CFIDE/administrator) does not.

    I need to create access to Excel in order to complete my code! Help?

    Best wishes
    CAT

    Cat,

    Technical note refers to a Troubleshooting page. The comments by Alexander mention providing the ColdFusion administrator password, when the script creates an instance of the Admin API. Try adding your administrator password to the
    installODBC.cfm file. Then, run the script again.

  • context menu in ColdFusion 8 ajax cfgrid

    I don't know if it's because Ext 1 vs 2 Ext, but in CF8 that uses Ext.
    There is no context menu when right clicking on the column header.

    However, Ext done doc have a nice menu contenxt, demonstration:
    http://ExtJS.com/deploy/ext/examples/grid/array-grid.html

    No idea how to activate this for CF8 CFGRID? I already tried to go in cfgrid.js
    and added & quot; enableColumnHide:true & quot; in the var _42 (line 18), but still no luck.

    Any help would be appreciated, thanks!

    2 NEW EXCELLENT TUTORIALS on the context menu for cfgrid controls!

    http://www.danvega.org/blog/index.cfm/2008/3/4/ColdFusion-8-grid-context-menus

    http://www.danvega.org/blog/index.cfm/2008/3/4/ColdFusion-8-grid-context-menu-part-II

    PS no, we don't need to 'change the line 18 by adding enableCtxMenu:true '.

    However, still can't hide CFGRIDROWINDEX...

  • Calendar of reports in ColdFusion

    Hi all

    I want to create a static web page with the content of a Report Builder report.

    I have a report very complex (four subreports) with lots of summary information and I can get it to work with the Builder, and I need to record the results of the report as a file HTML (cfm), he became one of the pages of my site. I tried to use the Scheduler in CF to auto run the report and exit then the file as HTML, but the resulting page is just rubbish. Does anyone know of a method to save or export a report to static HTML format?

    Thank you very much...

    Jim Pennington

    See http://livedocs.adobe.com/coldfusion/7/htmldocs/00000323.htm.
    Format options are "PDF" or "FlashPaper" or "Excel" or "RTF".
    Output in a format PDF or FlashPaper can serve as a functional web page with text, images, and hyperlinks.

Maybe you are looking for