How to Generate Excel File With Autofilters in PHP?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Okay, here's my dilemma.
I've been working on a Wordpress plugin for Medical Marcom to automatically update his List of US Twitter Doctors. Basically, it provides the ability to create a form where users can request to be added to the list, requests can be confirmed in the admin panel, when added they're available in the Excel file and the initial data is filled out, and finally, certain fields are automatically updated throughout the week.
Here's the problem.
My code is generating an Excel file with PHP using PHPExcel. However, I need to have a simple autofilter applied to the sheet at startup (honestly, I don't know what the big deal is... anyone can easily apply an autofilter in Excel, but he wants it available from the start). So, I tried applying the code I found:
$excel->getActiveSheet()->setAutoFilter('A1:J' . $row);
$excel is my PHPExcel instance. $row is the last row being outputted from the database. The file is generated immediately when the url is clicked and PHP's headers are set to translate the output as an Excel file, like so:
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=" . $file);
But when I open the file, no autofilters are set... I tried posting a question over at PHPExcel's website, but I didn't get any replies, so I decided to ask here.
Does anyone know what I may be doing wrong? For now he's going with the original file (updated a bit, though) until this issue is resolved.
php phpexcel autofilter
add a comment |
Okay, here's my dilemma.
I've been working on a Wordpress plugin for Medical Marcom to automatically update his List of US Twitter Doctors. Basically, it provides the ability to create a form where users can request to be added to the list, requests can be confirmed in the admin panel, when added they're available in the Excel file and the initial data is filled out, and finally, certain fields are automatically updated throughout the week.
Here's the problem.
My code is generating an Excel file with PHP using PHPExcel. However, I need to have a simple autofilter applied to the sheet at startup (honestly, I don't know what the big deal is... anyone can easily apply an autofilter in Excel, but he wants it available from the start). So, I tried applying the code I found:
$excel->getActiveSheet()->setAutoFilter('A1:J' . $row);
$excel is my PHPExcel instance. $row is the last row being outputted from the database. The file is generated immediately when the url is clicked and PHP's headers are set to translate the output as an Excel file, like so:
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=" . $file);
But when I open the file, no autofilters are set... I tried posting a question over at PHPExcel's website, but I didn't get any replies, so I decided to ask here.
Does anyone know what I may be doing wrong? For now he's going with the original file (updated a bit, though) until this issue is resolved.
php phpexcel autofilter
add a comment |
Okay, here's my dilemma.
I've been working on a Wordpress plugin for Medical Marcom to automatically update his List of US Twitter Doctors. Basically, it provides the ability to create a form where users can request to be added to the list, requests can be confirmed in the admin panel, when added they're available in the Excel file and the initial data is filled out, and finally, certain fields are automatically updated throughout the week.
Here's the problem.
My code is generating an Excel file with PHP using PHPExcel. However, I need to have a simple autofilter applied to the sheet at startup (honestly, I don't know what the big deal is... anyone can easily apply an autofilter in Excel, but he wants it available from the start). So, I tried applying the code I found:
$excel->getActiveSheet()->setAutoFilter('A1:J' . $row);
$excel is my PHPExcel instance. $row is the last row being outputted from the database. The file is generated immediately when the url is clicked and PHP's headers are set to translate the output as an Excel file, like so:
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=" . $file);
But when I open the file, no autofilters are set... I tried posting a question over at PHPExcel's website, but I didn't get any replies, so I decided to ask here.
Does anyone know what I may be doing wrong? For now he's going with the original file (updated a bit, though) until this issue is resolved.
php phpexcel autofilter
Okay, here's my dilemma.
I've been working on a Wordpress plugin for Medical Marcom to automatically update his List of US Twitter Doctors. Basically, it provides the ability to create a form where users can request to be added to the list, requests can be confirmed in the admin panel, when added they're available in the Excel file and the initial data is filled out, and finally, certain fields are automatically updated throughout the week.
Here's the problem.
My code is generating an Excel file with PHP using PHPExcel. However, I need to have a simple autofilter applied to the sheet at startup (honestly, I don't know what the big deal is... anyone can easily apply an autofilter in Excel, but he wants it available from the start). So, I tried applying the code I found:
$excel->getActiveSheet()->setAutoFilter('A1:J' . $row);
$excel is my PHPExcel instance. $row is the last row being outputted from the database. The file is generated immediately when the url is clicked and PHP's headers are set to translate the output as an Excel file, like so:
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=" . $file);
But when I open the file, no autofilters are set... I tried posting a question over at PHPExcel's website, but I didn't get any replies, so I decided to ask here.
Does anyone know what I may be doing wrong? For now he's going with the original file (updated a bit, though) until this issue is resolved.
php phpexcel autofilter
php phpexcel autofilter
asked Sep 8 '11 at 7:41
JaidynReimanJaidynReiman
6393922
6393922
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
In case anyone comes across this question. The feature has been implemented both for XLSX and XLS.
You just need to specify the range of your header row for it to work:
$excel->getActiveSheet()->setAutoFilter('A1:J1');
1
Only specifying the header row works. Thanks!
– Oak
Dec 3 '15 at 11:38
add a comment |
I understand from this link that it has not been implemented yet.
It seems like it is still a work item (with a low priority sorry).
[EDIT] seems like it may work with Excel 2007 (see this work item). Which version of Excel do your client use?
I'll have to ask him about it. I've seen that it HAS been implemented, and it shows it right in the documentation, but it didn't work for me. Another person who posted a work item apparently had got it working, it just didn't have the advanced features. I was starting to think, though, that I may have been trying to output the wrong type of Excel file. I'll go and ask my client if using Excel 2007 is fine. The current file is 2003, though, unfortunately...
– JaidynReiman
Sep 9 '11 at 3:10
add a comment |
PHPSpreadsheet have a much nicer implementation if you want your whole sheet auto-filtered:
$sheet->setAutoFilter(
$sheet->calculateWorksheetDimension()
);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7344707%2fhow-to-generate-excel-file-with-autofilters-in-php%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
In case anyone comes across this question. The feature has been implemented both for XLSX and XLS.
You just need to specify the range of your header row for it to work:
$excel->getActiveSheet()->setAutoFilter('A1:J1');
1
Only specifying the header row works. Thanks!
– Oak
Dec 3 '15 at 11:38
add a comment |
In case anyone comes across this question. The feature has been implemented both for XLSX and XLS.
You just need to specify the range of your header row for it to work:
$excel->getActiveSheet()->setAutoFilter('A1:J1');
1
Only specifying the header row works. Thanks!
– Oak
Dec 3 '15 at 11:38
add a comment |
In case anyone comes across this question. The feature has been implemented both for XLSX and XLS.
You just need to specify the range of your header row for it to work:
$excel->getActiveSheet()->setAutoFilter('A1:J1');
In case anyone comes across this question. The feature has been implemented both for XLSX and XLS.
You just need to specify the range of your header row for it to work:
$excel->getActiveSheet()->setAutoFilter('A1:J1');
answered Sep 20 '15 at 23:42
Maxime RainvilleMaxime Rainville
1,4441923
1,4441923
1
Only specifying the header row works. Thanks!
– Oak
Dec 3 '15 at 11:38
add a comment |
1
Only specifying the header row works. Thanks!
– Oak
Dec 3 '15 at 11:38
1
1
Only specifying the header row works. Thanks!
– Oak
Dec 3 '15 at 11:38
Only specifying the header row works. Thanks!
– Oak
Dec 3 '15 at 11:38
add a comment |
I understand from this link that it has not been implemented yet.
It seems like it is still a work item (with a low priority sorry).
[EDIT] seems like it may work with Excel 2007 (see this work item). Which version of Excel do your client use?
I'll have to ask him about it. I've seen that it HAS been implemented, and it shows it right in the documentation, but it didn't work for me. Another person who posted a work item apparently had got it working, it just didn't have the advanced features. I was starting to think, though, that I may have been trying to output the wrong type of Excel file. I'll go and ask my client if using Excel 2007 is fine. The current file is 2003, though, unfortunately...
– JaidynReiman
Sep 9 '11 at 3:10
add a comment |
I understand from this link that it has not been implemented yet.
It seems like it is still a work item (with a low priority sorry).
[EDIT] seems like it may work with Excel 2007 (see this work item). Which version of Excel do your client use?
I'll have to ask him about it. I've seen that it HAS been implemented, and it shows it right in the documentation, but it didn't work for me. Another person who posted a work item apparently had got it working, it just didn't have the advanced features. I was starting to think, though, that I may have been trying to output the wrong type of Excel file. I'll go and ask my client if using Excel 2007 is fine. The current file is 2003, though, unfortunately...
– JaidynReiman
Sep 9 '11 at 3:10
add a comment |
I understand from this link that it has not been implemented yet.
It seems like it is still a work item (with a low priority sorry).
[EDIT] seems like it may work with Excel 2007 (see this work item). Which version of Excel do your client use?
I understand from this link that it has not been implemented yet.
It seems like it is still a work item (with a low priority sorry).
[EDIT] seems like it may work with Excel 2007 (see this work item). Which version of Excel do your client use?
answered Sep 8 '11 at 7:45
JMaxJMax
20.7k85785
20.7k85785
I'll have to ask him about it. I've seen that it HAS been implemented, and it shows it right in the documentation, but it didn't work for me. Another person who posted a work item apparently had got it working, it just didn't have the advanced features. I was starting to think, though, that I may have been trying to output the wrong type of Excel file. I'll go and ask my client if using Excel 2007 is fine. The current file is 2003, though, unfortunately...
– JaidynReiman
Sep 9 '11 at 3:10
add a comment |
I'll have to ask him about it. I've seen that it HAS been implemented, and it shows it right in the documentation, but it didn't work for me. Another person who posted a work item apparently had got it working, it just didn't have the advanced features. I was starting to think, though, that I may have been trying to output the wrong type of Excel file. I'll go and ask my client if using Excel 2007 is fine. The current file is 2003, though, unfortunately...
– JaidynReiman
Sep 9 '11 at 3:10
I'll have to ask him about it. I've seen that it HAS been implemented, and it shows it right in the documentation, but it didn't work for me. Another person who posted a work item apparently had got it working, it just didn't have the advanced features. I was starting to think, though, that I may have been trying to output the wrong type of Excel file. I'll go and ask my client if using Excel 2007 is fine. The current file is 2003, though, unfortunately...
– JaidynReiman
Sep 9 '11 at 3:10
I'll have to ask him about it. I've seen that it HAS been implemented, and it shows it right in the documentation, but it didn't work for me. Another person who posted a work item apparently had got it working, it just didn't have the advanced features. I was starting to think, though, that I may have been trying to output the wrong type of Excel file. I'll go and ask my client if using Excel 2007 is fine. The current file is 2003, though, unfortunately...
– JaidynReiman
Sep 9 '11 at 3:10
add a comment |
PHPSpreadsheet have a much nicer implementation if you want your whole sheet auto-filtered:
$sheet->setAutoFilter(
$sheet->calculateWorksheetDimension()
);
add a comment |
PHPSpreadsheet have a much nicer implementation if you want your whole sheet auto-filtered:
$sheet->setAutoFilter(
$sheet->calculateWorksheetDimension()
);
add a comment |
PHPSpreadsheet have a much nicer implementation if you want your whole sheet auto-filtered:
$sheet->setAutoFilter(
$sheet->calculateWorksheetDimension()
);
PHPSpreadsheet have a much nicer implementation if you want your whole sheet auto-filtered:
$sheet->setAutoFilter(
$sheet->calculateWorksheetDimension()
);
answered Jan 3 at 10:07
Ng Sek LongNg Sek Long
595417
595417
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7344707%2fhow-to-generate-excel-file-with-autofilters-in-php%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown