N
N
nikitoshq2020-02-06 15:59:49
PHP
nikitoshq, 2020-02-06 15:59:49

How to write data to excel file in PHP?

There are 3 variables:
$id = $names_new[$j][0];
$old = $names_new[$j][1];
$new = $names_old[$i][1];
You need to write them to the Excel file line by line:
A BC
$id $old $new
Tried like this:

$id = $names_new[$j][0];
$old = $names_new[$j][1];
$new = $names_old[$i][1];
$tofile = $id  . ';' . $old . ';' . $new . "\n";
$bom = "\xEF\xBB\xBF";
@file_put_contents($fileall, $bom . $tofile . file_get_contents($fileall));

Does not work. Can someone tell me?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-02-06
@nikitoshq

$tofile = $id . ';' . $old . ';' . $new . "\n";
This is CSV, not XLS(X). To work with XLS(X) you can use PhpSpreadsheet

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question