|
|

Posted:
04-02-09, 07:58 PM
|
|
|
Mivite
|
 |
Joined Mar 2006
Posts: 111
|
|
Miva output header
Hi everyone,
I had to make a script lately that made me use the miva_output_header function. I wanted to share a small function that can be handy when someone wants to share files ( put files on download ) without making links.
I wrote an article here: http://mivascript.org/miva_script_fr...ad_script.html . Any comments welcomed...
PS: I promise i won't write a post for every function I share in the future  but this one can be tricky...
Thank you
Claudiu
| |
|
|
|
|

Posted:
04-03-09, 12:56 AM
|
|
|
Mega Mivite
|
 |
Joined Mar 2006
Posts: 1,021
|
|
Re: Miva output header
Hey Claudiu, are you reading my mind? I've been thinking about exactly this subject recently; I need this download capability for a project I'm working on. You just saved me some hours of reading, experimenting, and head-scratching.
I miss Ivo's contributions around here, but you're a good substitute  . Thanks --
| |
|
|
|
|

Posted:
04-03-09, 04:35 AM
|
|
|
Mivite
|
 |
Joined Mar 2006
Posts: 111
|
|
Re: Miva output header
Hi Kent
So glad it helps ! That's the big idea with the shared code  You have no idea how much your book helped (and still helps) me... so I should thank you first
Thanks
Claudiu
| |
|
|
|
|

Posted:
04-06-09, 09:11 AM
|
|
|
Mivite
|
 |
Joined Mar 2006
Posts: 111
|
|
Creating Excel files with Miva Script
While trying to find a way to create excel files on the fly, I found a dirty and ugly solution, that you can find here: http://mivascript.org/miva_script_create_excel.html
It's dirty, as we play with the header, and excel will see that the content of the file is not excel. But I'll try to find a solution for that matter too ...
Anyway, it's a good solution if you want to give the possibility to export excel file on Linux server, using Miva Script
Any comments welcomed !
Last edited by Claudiu; 04-06-09 at 09:14 AM..
| |
|
|
|
|

Posted:
04-09-09, 01:44 PM
|
|
|
Developer Partner
|
 |
Joined Dec 2006
Posts: 737
|
|
Re: Miva output header
I've done something very similar for streaming live .csv and txt reports out as a download.
As for excel, I've output a .csv file this way.
<MvASSIGN NAME = "l.null" VALUE = "{ miva_output_header('Content-type', 'application/vnd.ms-excel') }">
Excel is offered as the default program during the download dialog box, and opens the file just fine.
A note about .csv files; you need to make sure any data that contains commas gets wrapped in double quotes.
| |
|
|
|
|

Posted:
05-27-10, 05:40 PM
|
|
|
Mivite
|
Joined Nov 2008
Posts: 156
|
|
| |
|
|
|
|

Posted:
05-27-10, 09:49 PM
|
|
|
Mivite
|
 |
Joined Mar 2006
Posts: 111
|
|
Re: Miva output header
Hi Brian
Yes, indeed, the page is talking about forced download. The excel one is here: http://mivascript.org/miva_script_create_excel.html . I used the same link for the forum apparently
PS: Thanks Ray for your suggestion !
Best regards,
Claudiu
| |
|
|
|
|

Posted:
05-28-10, 11:36 AM
|
|
|
Mini Mivite
|
Joined Aug 2009
Posts: 24
|
|
| |
|
|
|
|

Posted:
05-28-10, 02:14 PM
|
|
|
Developer Partner
|
 |
Joined Dec 2006
Posts: 737
|
|
Re: Miva output header
The example is creating the data and outputing the file at the same time, so no physical file is ever created.
By setting the headers you get the browser 'file download" dialog box and the contents are streamed to your hard disk instead of to the browser screen.
Using Toolbelt, you can even do this in a Storemorph page template. Use Query to get the data, then format it as a simple tab separated text file.
I've created custom data export screens for several clients this way.
Last edited by RayYates; 05-28-10 at 02:19 PM..
| |
|
|
|
|

Posted:
05-29-10, 01:35 AM
|
|
|
Mivite
|
 |
Joined Mar 2006
Posts: 111
|
|
Re: Miva output header
Hi again,
Indeed, this way you cannot save the file, you can only stream it to the browser (and it's a very "amateur" approach with lots of inconvenient). I'll make the function to save the binary excel file this week and I'll post it here. I'll try to do it in mivascript (oh yes, it's possible) or in a C++ library (it's easier).
PS: I updated the excel page... You were right, I messed up the links and there was an example of the forced download, not the one with the excel file...
Cheers,
Claudiu
| |
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
|
Posting Rules |
|
|
|
|
All times are GMT -7. The time now is 02:07 PM.
|