I need a way to write an excel file with format through Pure PHP. WARNING:Please, this Q not about the libs, plugins and so on- do not disturb. I've googled a lot and didn`t find the Answer, but in some article on StackOverflow, some guy mentioned the HTML/CSS format way HTML format solutions that didn't work and I've tried to do this, but in file which was saved columns where filled with tags and nothing happens. May be there are some professionals who can help me with pure code writing an Excel through PHP, HTML, CSS or something.
And again with example, I've already used concept like this wich didn't help:
// headers for excel
$headers .= "<div style='font:bold 14px Times;'>Журнал остатков и инкассаций</div>\n";
$headers .= "Начало периода\t ".date('d.m.Y')."0:00 \n";
$headers .= "Начало периода\t ".date('d.m.Y')."23:59 \n\n";
$headers .= "Терминал\t";
$headers .= "Место расположения\t";
$headers .= "Дата\t";
$headers .= "Время\t";
$headers .= "Сумма инкассации\t";
$headers .= "Банкноты\t";
// excel content with overloaded terminals
if (mssql_num_rows($resCollection)>0) {
while ($rowCollection = mssql_fetch_object($resCollection)) {
$data .= $rowCollection->Name."\t".$rowCollection->Address."\t"
.$rowCollection->TerminalNotes."\t".$rowCollection->TerminalAmount
."\t".$rowCollection->DayAmountAll."\t"
.$rowCollection->LastPaymentTime."\n";
}
}
$fileName = 'collection'.date('d_m_Y_H_i_s').'.xls';
header("Content-type: application/vnd.ms-excel");// application/excel had also been used
header("Content-Disposition: attachment; filename=$fileName");
echo iconv('utf-8', 'cp1251', "$headers\n$data");
I've used not only divs and tables too - it didn't work though.