Trying to create a new excel file and name the file from the form

Topics: User Forum
Dec 31, 2015 at 12:36 AM
Hi,

Trying to create a new excel file and name the file from the form.
I can find heaps of example code where the file name is hard coded, but nothing where the file name is generated by user input.

sorry, I know this is probably basic, but I dont know much code.
Thanks.
Coordinator
Dec 31, 2015 at 12:39 AM
You use whatever you want to use as a filename, just use a variable value..... most of the examples generate the filename to use dynamically rather than using a gard-coded value
Dec 31, 2015 at 8:44 PM
I have a form using post function

Job No: <input type="text" name="jobno"><br

and the next php file uses this code

$objWriter->save("'jobno'.xlsx");

but its ignoring the variable thats being input
Coordinator
Dec 31, 2015 at 10:14 PM
So you're creating a file called literally 'jobno'.xlsx?!?

There's no use here of any PHP variables at all

If you're submitting the form via a POST request, then you'd be doing
$objWriter->save($_POST['jobno'] . ".xlsx");
But your issue isn't anything to do with PHPExcel, it's a lack of understanding of PHP variables. I suggest you start with a bit of reading