Skip to content

Commit 3515e19

Browse files
committed
Make content type configurable when sending file
1 parent beb3f4b commit 3515e19

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Property | Description
5454
Methods | Description
5555
---------|-------------
5656
`saveAs($name)` | Saves the excel file under `$name`
57-
`send($name=null,$inline=false)` | Sends the excel file to the browser. If `$name` is empty, the file is streamed for inline display, otherwhise a download dialog will open, unless `$inline` is `true` which will force inline display even if a filename is supplied.
57+
`send($name=null, $inline=false, $contentType = 'application/vnd.ms-excel')` | Sends the excel file to the browser. If `$name` is empty, the file is streamed for inline display, otherwhise a download dialog will open, unless `$inline` is `true` which will force inline display even if a filename is supplied.
5858
`createSheets()` | Only creates the sheets of the excel workbook but does not save the file. This is usually called implicitely on `saveAs()` and `send()` but can also be called manually to modify the sheets before saving.
5959
`getWriter()` | Returns the `PHPExcel_Writer_Abstract` instance
6060
`getWorkbook()` | Returns the `PHPExcel` workbook instance

src/ExcelFile.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ public function saveAs($filename)
106106
* streamed inline.
107107
* @param bool $inline whether to force inline display of the file, even if
108108
* filename is present.
109+
* @param string $contentType the Content-Type header. Default is
110+
* 'application/vnd.ms-excel'.
109111
*/
110-
public function send($filename = null, $inline = false)
112+
public function send($filename = null, $inline = false, $contentType = 'application/vnd.ms-excel')
111113
{
112114
$this->createFile();
113-
$this->getTmpFile()->send($filename, 'application/vnd.ms-excel', $inline);
115+
$this->getTmpFile()->send($filename, $contentType, $inline);
114116
}
115117

116118
/**

0 commit comments

Comments
 (0)