Spreadsheet_Excel_Writer trace issue

I tried the following program to write content in a Table. I also downloaded the Spreadsheet_Excel_Writer package.

<?php
ini_set('include_path','/xhome/rekha/public_html/PHP_FORUM/PHP/open_office/Spreadsheet_Excel_Writer-0.9.2/Spreadsheet/Excel/Writer.php');

$workbook = new Spreadsheet_Excel_Writer();
$workbook->send('grades.xls');
$format_bold =& $workbook->addFormat();

$format_bold->setBold();

$worksheet =& $workbook->addWorksheet();

$worksheet->write(0, 0, "NAME", $format_bold);
$worksheet->write(0, 1, "MARK1", $format_bold);
$worksheet->write(0, 2, "MARK2", $format_bold);
$worksheet->write(0, 3, "MARK3", $format_bold);
$worksheet->write(0, 4, "MARK4", $format_bold);
$worksheet->write(0, 5, "MARK5", $format_bold);
$worksheet->write(0, 6, "TOTAL", $format_bold);

$workbook->close();
?>

But during the execution of this php program, I received the following fatal error.

Fatal error: Class 'Spreadsheet_Excel_Writer' not found in /xhome/rekha/public_html/PHP_FORUM/PHP/open_office/spread.php on line 4
Call Stack
#   Time    Memory  Function    Location
1   0.0003  59868   {main}( )   ../spread.php:0

I tried to resolve this error. But I can not. Please help me resolve this error.

+3
source share
2 answers

you will need to enable the library, otherwise PHP will not recognize the Spreadsheet_Excel_Writer class.

And you also need to specify the path for include_path, not the file. And it is usually best to add a new path to an existing path. So first you will need to restore the current include_path and add a new path to this.

This should work:

<?php
ini_set('include_path',ini_get('include_path').':/xhome/rekha/public_html/PHP_FORUM/PHP/open_office/Spreadsheet_Excel_Writer-0.9.2/');

require_once 'Spreadsheet/Excel/Writer.php';

$workbook = new Spreadsheet_Excel_Writer();
$workbook->send('grades.xls');
$format_bold =& $workbook->addFormat();

$format_bold->setBold();

$worksheet =& $workbook->addWorksheet();

$worksheet->write(0, 0, "NAME", $format_bold);
$worksheet->write(0, 1, "MARK1", $format_bold);
$worksheet->write(0, 2, "MARK2", $format_bold);
$worksheet->write(0, 3, "MARK3", $format_bold);
$worksheet->write(0, 4, "MARK4", $format_bold);
$worksheet->write(0, 5, "MARK5", $format_bold);
$worksheet->write(0, 6, "TOTAL", $format_bold);

$workbook->close();
?>

, , Spreadsheet_Excel_Writer .

PEAR, PHP, . PEAR , include_path. , require_once. include_path.

:

pear install Spreadsheet_Excel_Writer-beta

, PEAR, ini_set script.

, .

PEAR: http://pear.php.net/manual/en/guide.users.commandline.cli.php

+3

, PHPExcel, XLS XSLX.

+2

Source: https://habr.com/ru/post/1737501/


All Articles