save a cfdocument as an excel file - excel

is there a workaround to use the cfdocument tag to save a page/file as an excel sheet instead of a PDF file?
I already have a process set up to make pdf files and email them out and would like to give my customers the option of getting an excel file instead. It would be nice if I could reuse the code I already have instead of having to rewrite it in POI or something like that.

The type of data witihn a PDF is not usually the same type of data that makes sense for Excel. That being said, there are multiple other ways to create Excel spreadhseets.
In ColdFusion 9, it's native. Just use the cfspreadsheet. In CF8... well, it looks like you have POI. So use that. ;) Ben Nadel also has a nice wrapper for POI so you can consider that too.
The thing is - you will not be able to go from CFDOCUMENT to a spreadsheet since it is really a different type of data.

In ColdFusion 9 use the cfspreadsheet tag and/or spreadsheet functions. That creates a real Excel file.
In ColdFusion 8 and below the easiest way is to use the html table > Excel hack/trick. Put your data in a standard html table, save them in a file with a .xls extension and email them to your users. When the user opens the file Excel will convert the html table to an Excel spreadsheet. You could also send the content to the browser by adding at the top of the page. With this method make sure that you are only sending an html table for best results.

Related

Power Query to open XML file formatted as Excel would open it

I have an XML file generated by EasyPower (electrical software). If I open the file in Excel it comes up as a series of formatted sheets like the image below. It appears this way without any prompts or dialogs.
I’m creating a Power Query routine that can extract the data from the sheets. Unfortunately when I use the Power Query wizard to select the XML file as a source, it doesn’t see the data as sheets, but rather a table with columns of Tables, seemingly an infinite number of levels deep. Digging through them I’m unable to clearly see the data. This is not a very good approach.
A work-around is for me to manually open the XML file with Excel and save it as XLSX, then it’s easy to work with the data in Power Query. I know a VBA script could be used to this but my question is, is there a way for Power Query to open an XML file and interpret the layout the same way that Excel does? This way would allow my script to also work within Power BI.
Edit: A sample file has been requested. This link will provide a very simple example containing two worksheets when opened in Excel. EasyPower_Test_Schedule.xml

Reading custom data format into Excel VBA

I have a file of extension *.qub that I would like to read into Excel. The file contains spacecraft instrument data. The file has two parts, a SFDU-defined text header followed by binary data.
Ideally, we would like the user to be able to access the files using Excel's built-in File-->Open and File-->Save functionality to import/export this *.qub format.
What is the best way to create a custom file reader/writer in Excel?
Thank you!

How to export Reports in Microsoft Access in a specific manner

I have a client that reads their reports in Microsoft access...the woe is she tries to export the report to an excel file by right clicking on the report and going to export->Excel
This works, but the labels are not in the right order etc... in the report they are right..but in the exported file they need more data (or she wants more). I have to say I am perplexed how to somehow intercept the export and write my own xls file out based on the query that generated the report... or some other way? Maybe another report that is generated that is for the sole purpose of exporting that has the columns in the final xls file the way she wants...I am not a guru at this just know enough to be dangerous so I am not sure what the best method to attack this is and get it where the exported report as an excel file has the columns she wants.
You have two options one is more efficient and one more flexible:
More efficient:
Write the query to a CSV file file using IO statements
More flexible:
Build the Excel file cell by cell using an Excel object. Of course you can use loops and make it generic so it will work with any query passed as a parameter

Convert richtext strings to excel

I have a form that has TinyMCE for richtext formatting. All of our data is available to export as an HTML report, PDF Report, and Excel Spreadsheet (report).
The fields, that we allow richtext in, show up as the formatted values in both the HTML and PDF reports, but in Excel we show them as strings. For instance:
<b>this part is bold</b><br />line 2 here.
I need a way to make that show up as bold/line-break in excel rather then just showing that string, or at least a way to strip the HTML tags out of there and just show plain text (though I would really like to at least keep the line breaks). Is there some type of macro I can include in the excel download or some C++ program that can convert it or something?
Thanks for your time!
I've done something similar with PHPExcel
The trick is to take your formatted data and find a pattern. In your case, it would probably be table rows/table cells. Iterate through that structure setting the excel cell values as you go. For complex formatting you could fairly simply regex replace what is necessary to get formatted as you desire. The theory may sound a little complicated, but once you get down to it, it's only an hour or two's worth of work.
Certainly there are equivalent programs based on other server technologies. But this one has worked brilliantly for me over the years, and I trust it to work on sites for very big clients with crazy inbound traffic numbers...and it's never failed. It's the only reliable way I've found to write perfect, properly formatted Excel without requiring the user to jump through hoops to get a specific browser.

How do I display a counter(ie, no. of times downloaded) in an MS Excel 07 spreadsheet when the spreadsheet(.xls) is downloaded off my webpage?

I know it is easy to display a counter on a webpage but I need to implement the same, ie, I need to write data to a cell in the Excel 2007 spreadsheet every time a person downloads it from my webpage.
To be more precise, when the user downloads the excel file to his hard drive and when it is opened, I want the spreadsheet to display the number of times the .xls file has been downloaded, in a cell (ofcourse along with other cells containing data).
I just need to figure out how do i programmmatically communicate with Excel 07 sheet.
That sounds like an exercise in futility since the number will be out of date as soon as the next person downloads the file. Is this what you really want to do?
If yes, it's very possible using some server-side scripts. PHP, Perl and other languages all have libraries that can be used to edit Excel files programmatically. Pick the one you are most comfortable with and go from there.
EDIT:
I think the best way to go since you control both the Excel file and the website is to add a counter to the website, and reference it in your Excel file via web queries. If you're not familiar with web queries, they are a tool in excel that let you import tables from the web that will be refreshed everytime the file loads (or even if a user hits refresh). Here's more information about the Web Query Tool.
Let me know if this solution works for you.
EDIT2:
Here's a link to a more up-to-date tutorial.

Resources