Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2009
    Location
    South Africa - Johannesburg
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How do I exprot data in a grid to an Excel file?

    I Created a link (ToExcelLink) on my page (outside the grid) to export the data in the Grid to an excel file. Part of the export works because the excel file is created with the controls of my page. But the grid with the data is missing. What am I missing?

    The link's Default value is "Export to Excel"
    The href source is "Score_Card_Show_All.ccp" (My page's name)
    The link parameter name is "export"
    The link parameter source type is "Expression"
    The link parameter source is "1"

    The code in my grid's BeforeSelect event:

    function EditableGrid1_BeforeSelect(& $sender)
    {
    $EditableGrid1_BeforeSelect = true;
    $Component = & $sender;
    $Container = & CCGetParentContainer($sender);
    global $EditableGrid1; //Compatibility

    if (CCGetFromGet("export") == "1") {
    //Show up to 10,000 records
    $EditableGrid1->PageSize = 10000;
    $EditableGrid1->ds->PageSize = 10000;
    //Hide the Navigator
    $EditableGrid1->Navigator->Visible = false;
    }

    return $EditableGrid1_BeforeSelect;
    }

    The code in my page's OnInitializeView event:

    function Page_OnInitializeView(& $sender)
    {
    $Page_OnInitializeView = true;
    $Component = & $sender;
    $Container = & CCGetParentContainer($sender);
    global $Score_Card_Show_All; //Compatibility

    global $ToExcelLink;
    global $Header;
    global $Link1;

    $ExportFileName = "Report.xls";
    if (CCGetFromGet("export") == "1") {
    //Hide the ToExcelLink Link
    $ToExcelLink->Visible = false;
    $Link1->Visible = false;
    $Header->Visible = false;

    //Set Content type to Excel
    header("Content-Type: application/vnd.ms-excel");
    //Fix IE 5.0-5.5 bug with Content-Disposition=attachment
    if (strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 5.5;") ||
    strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 5.0;")) {
    header("Content-Disposition: filename=" . $ExportFileName);
    } else {
    header("Content-Disposition: attachment; filename=" . $ExportFileName);
    }
    }

    return $Page_OnInitializeView;
    }

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    $ToExcelLink->Visible = false;
    $Link1->Visible = false;
    $Header->Visible = false;
    I think you are confusing PHP with a client-side language (Javascript, etc). PHP is on the server side of things.

  • #3
    New to the CF scene
    Join Date
    Feb 2009
    Location
    South Africa - Johannesburg
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Oops, sorry! New to this site. Will try to figure out how to move this thread to the correct forum.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    No problem, I'll move this.
    What is this, json? It looks like PHP code, but it appears to have event handlers, so I'm not sure...
    One of the client mods can always move it back
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    New to the CF scene
    Join Date
    Feb 2009
    Location
    South Africa - Johannesburg
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I solved my issue my changing the link's preserve paramemters to 'GET and POST'. Used to be 'None'.
    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •