0
I need to recover data from an HTML form and send to an Excel file, there is some way with Javascript or PHP?
0
I need to recover data from an HTML form and send to an Excel file, there is some way with Javascript or PHP?
1
There is a form answered in a Stackoverflow post in English. You can adapt the code according to what you want. Follow the link: https://stackoverflow.com/questions/18704449/export-html-form-data-to-excel
0
To handle Excel files in PHP I work with the library csv. To install the package you will need to use the commiserate.
To create a file with this library is very easy.
Create a header
$header = ["nome" , "email", "contato", "messagem", "empresa"];
Your Data
$contents = [
['Fulano da Silva', "fulano.silva@...", 9999999999, 'Texto', StackOverflow],
['Ciclano da Silva', "ciclano.silva@...", 9999999999, 'Texto', StackOverflow]
];
Calling the library
$writer = Writer::createFromFileObject(new SplTempFileObject());
//Criando um arquivo CSV temporário
$writer->setDelimiter("\t"); //Caracter delimitador
$writer->setNewline("\r\n"); //Forma do windows aplicar o quebra-linha
$writer->setOutputBOM(Writer::BOM_UTF8);
//Saída das informações respeitando os caráteres especiais
$writer->insertOne($header);
$writer->insertAll($contents);
If you want to download the file add the lines
$writer->setEncodingFrom('ISO-8859-15');
$writer->output('firstname.csv');
More information
Browser other questions tagged php javascript html
You are not signed in. Login or sign up in order to post.
Thank you very much!
– Nicolas Fukuyama