Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once $_SERVER['DOCUMENT_ROOT'].'/lib/Spout/Autoloader/autoload.php';
- use Box\Spout\Common\Type;
- use Box\Spout\Writer\Style\Border;
- use Box\Spout\Writer\Style\BorderBuilder;
- use Box\Spout\Writer\Style\Color;
- use Box\Spout\Writer\Style\StyleBuilder;
- use Box\Spout\Writer\WriterFactory;
- $ID=(int)$ID;
- $border = (new BorderBuilder())
- ->setBorderBottom(Color::BLACK, Border::WIDTH_THIN, Border::STYLE_SOLID)
- ->setBorderTop(Color::BLACK, Border::WIDTH_THIN, Border::STYLE_SOLID)
- ->setBorderLeft(Color::BLACK, Border::WIDTH_THIN, Border::STYLE_SOLID)
- ->setBorderRight(Color::BLACK, Border::WIDTH_THIN, Border::STYLE_SOLID)
- ->build();
- $style = (new StyleBuilder())
- ->setBorder($border)
- ->setFontBold()
- ->setFontColor(Color::BLACK)
- ->setBackgroundColor(Color::YELLOW)
- ->build();
- ####
- $writer = WriterFactory::create(Type::XLSX);
- if($dir) $writer->openToFile($dir.$filePath.'.xlsx');
- else $writer->openToBrowser($filePath.'.xlsx');
- $writer->getCurrentSheet()->setName('Price');
- $singleRow=array('Производитель',
- 'Артикул',
- );
- $writer->addRowWithStyle($singleRow, $style);
- $sql='SELECT ';
- $result=$this->sqli->real_query($sql);
- do {
- /* получаем первый результирующий набор */
- if ($result = $this->sqli->use_result()) {
- while ($row = $result->fetch_assoc()) {
- $writer->addRow(array( $row['brand'],
- $row['art'],
- ));
- }
- $result->close();
- }
- unset($row);
- if (!$this->sqli->more_results())break;
- } while ($this->sqli->next_result());
- $writer->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement