KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Export to Excel not working correctly #2152

Open Richb201 opened this topic on on Jun 22, 2021 - 5 comments

Richb201 commented on Jun 22, 2021

When I export to Excel suddenly the document is appearing like this. How can I fix this?

This is how i am building it:

    public function sixty765()
    {
        $this->exec_summary();  //build the array
        $title = sprintf("proforma 6765 for %s. warning: this spreadsheet is just a sample and should not be relied upon without expert due diligence", $this->session->userdata('campaign'));
        $description = sprintf("Sample of 6765");
        $report = new MyExport6765;
        $report->run()->exportToExcel(array(
            "properties" => array(
                "creator" => "Research Study Online",
                "title" => $title,
                "description" => $description,
                "subject" => "sample 6765",
                "keywords" => "",
                "category" => "",
            )
        ))->toBrowser($this->session->userdata('campaign') . " proforma results.xlsx");

        $report->run()->render();
    }
Richb201 commented on Jun 23, 2021

Can you at least tell me if this is a problem with exportToExcel or a problem with my setup of LibreOffice?

Sebastian Morales commented on Jun 23, 2021

You have some redundant blank space output before the excel content. Pls try adding the following commands to your function:

    public function sixty765()
    {
        ob_start(); //turn on buffering to disable redundant output
        $this->exec_summary();  //build the array
        $title = sprintf("proforma 6765 for %s. warning: this spreadsheet is just a sample and should not be relied upon without expert due diligence", $this->session->userdata('campaign'));
        $description = sprintf("Sample of 6765");
        $report = new MyExport6765;
        ob_end_clean(); //turn off buffering to start output excel
        $report->run()->exportToExcel(array(
            "properties" => array(
                "creator" => "Research Study Online",
                "title" => $title,
                "description" => $description,
                "subject" => "sample 6765",
                "keywords" => "",
                "category" => "",
            )
        ))->toBrowser($this->session->userdata('campaign') . " proforma results.xlsx");
        exit; //quit right after export excel or pdf, we don't want redundant output after the content.
        //$report->run()->render(); //comment out this command because it's redundant
    } 
Richb201 commented on Jun 23, 2021

Thx. I made the changes but am getting the same thing. Please note: I actually have two different places where I am exporting Excel in my app with two different sections of code. Both are exporting with those crazy chars and both started doing on the same day. That is why I thought that it might be my copy of LibreOffice Calc. To me it seems that the import somehow got screwed up.

Is there any possibility that my Libreoffice Calc go screwed up and it is not Koolreport at all?

Sebastian Morales commented on Jun 28, 2021

I don't think it's LibreOffice's fault. I can see a zero (0) character at the beginning of your excel file, which should not be there. Please open the file in a text editor and remove the zeros character, save the file, and try to open it with LibreOffice again. Tks,

Richb201 commented on Jun 28, 2021

Sebastion, I saved the file so that I could send it to a consultant. Once I did that Libre office went back to working normally. So all is AOK.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

None