Reputation: 159
Need help! I'm just new in php and dont know how to export a data from database to excel.
The excel format must be like this:
Can you help me or suggest a function where this format can be make? The Headers like Hit Rate,Production Time, Service Time will be hard coded. The YC Alabang,and all the records under the headers will be coming from database. Thanks!
Upvotes: 1
Views: 4716
Reputation: 2125
You can also use EasyXLS Excel library. The pic shows me that you need to export an Excel file from database, with the cell from headers merged, borders and gray background.
This link shows you how to export data from database to Excel in PHP. It has a special section on this matter only:
http://www.easyxls.com/manual/FAQ/export-to-excel-in-php-asp.html
This link shows how to set the borders and cell background: http://www.easyxls.com/manual/basics/format-excel-cells.html
like
$xlsStyleHeader->setBackground((int)$COLOR_GRAY);
$xlsStyleHeader->setBorderColors ((int)$COLOR_GRAY, (int)$COLOR_GRAY,
(int)$COLOR_GRAY, (int)$COLOR_GRAY);
$xlsStyleHeader->setBorderStyles ($BORDER_BORDER_MEDIUM, $BORDER_BORDER_MEDIUM,
$BORDER_BORDER_MEDIUM, $BORDER_BORDER_MEDIUM);
This links shows you how to merge the cells: http://www.easyxls.com/manual/basics/excel-merge-cells.html like
$xlsTable = $workbook->easy_getSheet("Sheet1")->easy_getExcelTable();
$xlsTable->easy_mergeCells_2("A1:C3");
Upvotes: 0
Reputation: 3189
You can use PHPExcel library. With this library, you can compose the excel file with any complex of header structure.
Also please check this article on Stackoverflow
How to export data to an excel file using PHPExcel
This link will give you better look on coding style.
Upvotes: 1