Coder Social home page Coder Social logo

Comments (2)

viest avatar viest commented on May 12, 2024 1

Hi @boedyirh

Thank you for your support, extensions do not have built-in direct download, but can be implemented through the following code:

function getTmpDir(): string
{
    if (ini_get('upload_tmp_dir') !== false) {
        if ($temp = ini_get('upload_tmp_dir')) {
            if (file_exists($temp)) {
                return realpath($temp);
            }
        }
    }

    return realpath(sys_get_temp_dir());
}

$config = [
    'path' => getTmpDir() . '/',
];

$fileName   = 'tutorial01.xlsx';
$xlsxObject = new \Vtiful\Kernel\Excel($config);

// Init File
$fileObject = $excel->fileName($fileName);

// Writing data to a file ......

// Outptu
$filePath = $fileObject->output();

// Set Header
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $fileName . '"');
header('Cache-Control: max-age=0');

if (copy($filePath, 'php://output') === false) {
    // Throw exception
}

// Delete temporary file
@unlink($filePath);

I hope this will help you.

from php-ext-xlswriter.

boedyirh avatar boedyirh commented on May 12, 2024

Thanks it works! I am able to download it.
I modify MIME Type to match XLSX (Excel 2007).
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

from php-ext-xlswriter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.