如何在PHPExcel保存时选择路径
怎么在PHPExcel保存时选择路径?
请问使用PHPExcel导出Excel是如何可以自己选择保存路径??
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> set_include_path(get_include_path() . PATH_SEPARATOR . LIB_DIR.DIRECTORY_SEPARATOR."PHPExcel".DIRECTORY_SEPARATOR."Classes"); include 'PHPExcel.php'; include 'PHPExcel/IOFactory.php'; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("Maarten Balliauw"); $objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw"); $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document"); $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document"); $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes."); $objPHPExcel->getProperties()->setKeywords("office 2007 openxml php"); $objPHPExcel->getProperties()->setCategory("Test result file"); $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello'); $objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!'); $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello'); $objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!'); $objPHPExcel->getActiveSheet()->setTitle('Simple'); $objPHPExcel->setActiveSheetIndex(0); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); //以下为保存 //下面两句直接就保存到当前目录了 $outputFileName = "output.xlsx"; $objWriter->save($outputFileName); //而我想在保存前提示用户自己选择路径,就采用了如下方法(摘自网上),可是他直接输出到浏览器了,不没有提示保存 header("Content-Type: application/force-download"); header('Content-Disposition:inline;filename="'.$outputFileName.'"'); header("Content-Transfer-Encoding: binary"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); $objWriter->save('php://output');
------解决方案--------------------
帮顶!
------解决方案--------------------
- PHP code
header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/download"); header("Content-Disposition: attachment;filename=$outputFileName"); header("Content-Transfer-Encoding: binary "); <br><font color="#e78608">------解决方案--------------------</font><br>主要是这句<br>header('Content-Disposition:inline;filename="'.$outputFileName.'"'); <br>改<br>header("Content-Disposition: attachment;filename=$outputFileName"); <br><font color="#e78608">------解决方案--------------------</font><br>没问题啊,你原本的代码就可以<br><br>只是第二行会出错<br>set_include_path(get_include_path() . PATH_SEPARATOR . LIB_DIR.DIRECTORY_SEPARATOR."PHPExcel".DIRECTORY_SEPARATOR."Classes");<br>改成下面就可以了<br>//set_include_path(get_include_path() . PATH_SEPARATOR . LIB_DIR.DIRECTORY_SEPARATOR."PHPExcel".DIRECTORY_SEPARATOR."Classes");<br> <br><font color="#e78608">------解决方案--------------------</font><br>顶 <br><font color="#e78608">------解决方案--------------------</font><br>帮顶一下 <div class="clear"> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

[SpringBoot] Passing parameters in the Header through Feign calls How to pass Header parameters through Feign Problem description When we use Feign to request the Api interface of another service in Spring Cloud, there is a need to pass the parameters in the Header. If no special processing is done, it will The parameters in the Header will be lost. Solution 1: Pass it through @RequestHeader(name="headerName"). For example: Feign is defined as follows @FeignClient(name="service-name")pub

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

The Linux header refers to the beginning of a file or data stream, which is used to contain metadata about the content. By correctly writing and using Header files, developers can better utilize system resources and improve code readability and Maintainability.

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

PHP is a powerful programming language that can be used to create dynamic websites and web applications. One of the most powerful features is PHP’s header() method. In this article, we will explore how to use PHP’s header() method to adjust web pages.

How to implement jump in php header: 1. Use "Header("Location:$url");" syntax to implement jump; 2. Use if judgment to implement jump, with jump statements such as "if($_COOKIE[" u_type"]){ header('location:register.php'); } else{ setcookie('u_type','1','86400*360');".

Differences: 1. The head tag is used to define the head of the document, which is a container for all head elements, and the header tag is used to define the header (introduction information) of the document; 2. All browsers support the head tag, and older versions of browsers None of the browsers support the header tag, and browsers such as IE9+ and above are required to support the header tag.
