0

I am using shared server i have a cpanel access but not finding any way to implement.

i'm getting this error but can't found any solution for shared server.

PHP Fatal error:  Class 'COM' not found

Below code php file code:

// include("DataType.inc");

header("Content-Type: text/html");

echo "Tutorial 29<br>";
echo "----------<br>";

// Create an instance of the class that exports Excel files
$workbook = new COM("EasyXLS.ExcelDocument");

// Create two sheets
$workbook->easy_addWorksheet_2("First tab");
$workbook->easy_addWorksheet_2("Second tab");

// Get the table of data for the first worksheet
$xlsFirstTable = $workbook->easy_getSheetAt(0)->easy_getExcelTable();

// Add data in cells for report header
for ($column=0; $column<5; $column++)
{
    $xlsFirstTable->easy_getCell(0,$column)->setValue("Column " . ($column + 1));
    $xlsFirstTable->easy_getCell(0,$column)->setDataType($DATATYPE_STRING);
}

// Add data in cells for report values
for ($row=0; $row<100; $row++)
{
    for ($column=0; $column<5; $column++)
    {
        $xlsFirstTable->easy_getCell($row+1,$column)->setValue("Data ".($row + 1).", ".($column + 1));
        $xlsFirstTable->easy_getCell($row+1,$column)->setDataType($DATATYPE_STRING);
    }
}

// Set column widths
$xlsFirstTable->easy_getColumnAt(0)->setWidth(100);
$xlsFirstTable->easy_getColumnAt(1)->setWidth(100);
$xlsFirstTable->easy_getColumnAt(2)->setWidth(100);
$xlsFirstTable->easy_getColumnAt(3)->setWidth(100);

// Export the XLSB file
echo "Writing file: C:\Samples\Tutorial29.xlsb<br>";
$workbook->easy_WriteXLSBFile("./Tutorial29.xlsb");

// Confirm export of Excel file
if ($workbook->easy_getError() == "")
    echo "File successfully created.";
else
    echo "Error encountered: " . $workbook->easy_getError();

// Dispose memory
$workbook->Dispose();

Anyone have solution for this kind of issue advance thank you.

Bijender Singh Shekhawat
  • 3,934
  • 2
  • 30
  • 36

1 Answers1

0

The error is cause by the PHP server that does not support the COM dlls written in .NET. You must add an extension to your PHP server in php.ini file.

extension=php_com_dotnet.dll 

https://www.easyxls.com/manual/troubleshooting/class-com-not-found.html

UPDATE: This is the solution for the error that you get, but I have just noticed that you are on Unix. The COM objects are not supported on Unix. You must install EasyXLS for Java and also PHP/Java Bridge.

alex.pulver
  • 2,107
  • 2
  • 31
  • 31