Jump to content

PHP COM objects


244863

Recommended Posts

Any ideas??

 

ERROR = Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Unknown<br/><b>Description:</b> Unknown' in c:\Inetpub\wwwroot\hr\workforceonline\update\relienceReg.php:41 Stack trace: #0 c:\Inetpub\wwwroot\hr\workforceonline\update\relienceReg.php(41): variant->Cells(34, 257) #1 {main} thrown in c:\Inetpub\wwwroot\hr\workforceonline\update\relienceReg.php on line 41

 

CODE =

 

$workbook = "registers.xls";

 

#Instantiate the spreadsheet component.

    $ex = new COM("Excel.sheet") or Die ("Did not connect");

 

#Get the application name and version   

    print "Application name:{$ex->Application->value}<BR>" ;

    print "Loaded version: {$ex->Application->version}<BR>";

 

#Open the workbook that we want to use.

    $wkb = $ex->application->Workbooks->Open($workbook) or Die ("Did not open");

 

    $date = date('d-M-Y');

    #$ex->Application->Visible = 1; #Uncomment to make Excel visible.

 

# Read and write to a cell in the new sheet

# We want to read the cell E11 (Advertising in the 4th. Quarter)

    $sheets = $wkb->Worksheets->Add();    #Select the sheet

    $sheets->activate;                #Activate it

   

$sql = 'select * from ' . oracle_database . '."VRELIENCEREG"';

$sql = OCI_Parse ( $conn2, $sql );

OCI_Execute ( $sql );

$rownum = 6;

$col = 1;

 

while ( OCI_Fetch ( $sql ) ) {

   

$row = oci_fetch_row($sql);

 

  foreach($row as $value){

 

    $cell = $sheets->Cells($rownum,$col) ;    #Select the cell (Row Column number)

    $cell->activate;                #Activate the cell

    $cell->value = $value;            #Change it

    print "New value = {$cell->value}<BR> ";#Print the new value

   

    $col++;

  }

 

  $rownum++;

}

   

#Optionally, save the modified workbook

    $ex->Application->ActiveWorkbook->SaveAs($date);                     

#Close all workbooks without questioning

    $ex->application->ActiveWorkbook->Close("False");   

    unset ($ex);

Link to comment
https://forums.phpfreaks.com/topic/163337-php-com-objects/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.