Support » Plugin: Gravity Forms Entries in Excel » Download all results of multiple forms

  • Resolved valousal

    (@valentinanamorphik)


    I want to download directly from the forms table without the url!

    Allright! No need to yell! For those situation we’ve added a bulk option on the forms table.
    As a bonus, you can select multiple forms, and it will download all results in one file,
    on multiple worksheets (oohhh yeah!)

    Can I download all results in one file from all forms with a URL as on each form?

    Thank you !

    • This topic was modified 7 months, 2 weeks ago by valousal.
    • This topic was modified 7 months, 2 weeks ago by valousal. Reason: markdown
Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Doeke Norg

    (@doekenorg)

    Hi @valentinanamorphik,

    These is no native support for this. Reason is mostly because this is not really a much requested thing, and also security. When someone has this url, he or she has access to every entry, including forms that will be made in the future. I see this as a bad thing. That’s why I’m not keen on implementing this.

    However, it’s possible to hack something together within a project. What kind of url are thinking about? Maybe I can help you get started on a private implementation.

    valousal

    (@valentinanamorphik)

    Hi @doekenorg ,

    Thank you for your reply.

    We understand perfectly why you are not keen on implementing this in your project.
    However, we need this export temporarily.

    We are developer, we can implement this feature in our project.

    Example URL: https://www.mysite.com/gf-entries-in-excel/{token}?forms=all

    Regards,

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @valentinanamorphik,

    That particular url isn’t possible because a token references a specific form. But I got some ideas.

    Let me get back to you on this.

    valousal

    (@valentinanamorphik)

    Hi @doekenorg,

    Thank you.

    Most important. We need to access the export with a URL;)

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @valentinanamorphik,

    I’ve hacked something together for you. This exports all active and untrashed forms into one excel on multiple sheets. You can refactor this to a nice class. Just make sure that the request has a priority lower than 10 as to be earlier than the normal hook.

    // Quick and dirty, but does the trick.
    use GFExcel\GFExcel;
    use GFExcel\GFExcelOutput;
    use GFExcel\Renderer\PHPExcelMultisheetRenderer;
    
    add_action('request', function ($query_vars) {
        // only respond to a plugin call
        if (!array_key_exists(GFExcel::KEY_ACTION, $query_vars) ||
            !array_key_exists(GFExcel::KEY_HASH, $query_vars) ||
            $query_vars[GFExcel::KEY_ACTION] !== GFExcel::$slug) {
            return $query_vars;
        }
    
        // Set this super secret key to something only u know.
        $secret = 'super_secret';
        if ($query_vars[GFExcel::KEY_HASH] !== $secret) {
            return $query_vars;
        }
    
        // instantiate multi sheet renderer and push all forms to it.
        $renderer = new PHPExcelMultisheetRenderer();
        foreach (GFFormsModel::get_form_ids() as $form_id) {
            $output = new GFExcelOutput((int) $form_id, $renderer);
            $output->render();
        }
    
        // start the rendering and the download.
        $renderer->renderOutput();
        exit;
    }, 9);

    Hope this helps you out.

    Edit: You can download this file by going to: <your-url.ext>/gf-entries-in-excel/super_secret 🙂

    • This reply was modified 7 months, 2 weeks ago by Doeke Norg. Reason: Forgot the url
    valousal

    (@valentinanamorphik)

    Hi @doekenorg,

    Great.

    Thanks a lot for your help !!

    Plugin Author Doeke Norg

    (@doekenorg)

    @valentinanamorphik sure, no problem. Enjoy!

    valousal

    (@valentinanamorphik)

    Hi @doekenorg,

    Sorry to bother you again…

    Is it possible to extract in a Excel single sheet?

    Thanks !!

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @valentinanamorphik,

    In theory you could do that. But we would need to build a MultiSingleSheetRenderer. That feels weird 😀.

    That would be custom to your installation only. And I can’t promise much support for it.

    I’ll take a look. Will get back to you on this.

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @valentinanamorphik,

    Here you find a custom renderer:
    https://gist.github.com/doekenorg/b7fdfca59a98e2d36ebca0785d333976

    You’ll need to save the file, and include it somewhere in your functions.php or add it to a location you know is autoloaded.

    NB. The styling is removed; can’t do much about that other than completely rewriting a renderer; and that idea sounds like no fun 🙂

    Hope this helps you out.

    valousal

    (@valentinanamorphik)

    That’s great !!

    valousal

    (@valentinanamorphik)

    It’s correct ?

    
    // include : https://gist.github.com/doekenorg/b7fdfca59a98e2d36ebca0785d333976
    require 'MultiFormSingleSheetRenderer.php';
    
    // Quick and dirty, but does the trick.
    use GFExcel\GFExcel;
    use GFExcel\GFExcelOutput;
    use GFExcel\Renderer\PHPExcelMultisheetRenderer;
    
    add_action('request', function ($query_vars) {
        // only respond to a plugin call
        if (!array_key_exists(GFExcel::KEY_ACTION, $query_vars) ||
            !array_key_exists(GFExcel::KEY_HASH, $query_vars) ||
            $query_vars[GFExcel::KEY_ACTION] !== GFExcel::$slug) {
            return $query_vars;
        }
    
        // Set this super secret key to something only u know.
        $secret = 'super_secret';
        if ($query_vars[GFExcel::KEY_HASH] !== $secret) {
            return $query_vars;
        }
    
        // instantiate multi sheet renderer and push all forms to it.
        // $renderer = new PHPExcelMultisheetRenderer();
        $renderer = new MultiFormSingleSheetRenderer();
        foreach (GFFormsModel::get_form_ids() as $form_id) {
            $output = new GFExcelOutput((int) $form_id, $renderer);
            $output->render();
        }
    
        // start the rendering and the download.
        $renderer->renderOutput();
        exit;
    }, 9);
    

    Regards,

    • This reply was modified 6 months, 3 weeks ago by valousal. Reason: fix markdown
    • This reply was modified 6 months, 3 weeks ago by valousal. Reason: fix markdown
    Plugin Author Doeke Norg

    (@doekenorg)

    @valentinanamorphik,

    You need to save this page (https://gist.githubusercontent.com/doekenorg/b7fdfca59a98e2d36ebca0785d333976/raw/fb99c03e5dcf45fd5f39f55650aec71d954ff920/MultiFormSingleSheetRenderer.php) as MultiFormSingleSheetRenderer.php and store it in your installation.

    Then you include the file in your functions.php:

    <?php
    // ... 
    include_once "path/to/your/MultiFormSingleSheetRenderer.php";
    

    Then you change this

    // instantiate multi sheet renderer and push all forms to it.
        $renderer = new PHPExcelMultisheetRenderer();

    to this:

    // instantiate multi sheet renderer and push all forms to it.
        $renderer = new MultiFormSingleSheetRenderer();

    That should do the trick!

    Plugin Author Doeke Norg

    (@doekenorg)

    @valentinanamorphik sorry, I couldn’t see your post. It was missing, so I went on the message in the mail. That looked a bit different. But yes; that looks right enough. Is it working?

    You can loose the use GFExcel\Renderer\PHPExcelMultisheetRenderer; stament as you no longer use that.

    valousal

    (@valentinanamorphik)

    Hi @doekenorg ,

    We have the entries of the first form but not the others (4 in total).

    We have forms without entries yet. Maybe because of that?

    Results : https://file.io/mwVSv3

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Download all results of multiple forms’ is closed to new replies.