Jump to content

Windows Server 2k8 R2 and COM Excel


Andy-H

Recommended Posts

I am trying to run a COM application that I wrote (that worked perfectly on XP / XAMPP) on windows server 2k8 and it doesn't work, I tried running it under IIS to no avail and now am trying XAMPP, I have apache 2.2 set to interact with desktop and the Excel.Visible and Excel.ScreenUpdating properties set to true.

 

I see the Excel process created in task manager and can retrieve values from field ranges and print them to the screen, but the screen does not update, the real problem though comes when I try to save a workbook.

 

public function save($filename = false, $type = false)
{
//60    .ods
//-4143 .xls
  //save and close workbook
  if ( $filename )
  {
   switch($type)
   {
    case 'xls':
     $type = -4143;
     $ext  = 'xls';
    break;
    case 'ods':
     $type = 60;
     $ext  = 'ods';
    break;
    default:
     $type = false;
     $ext  = 'xlsx';
    break;
   }
   if ( $type )
   {
    $this->_wb->SaveAs($filename, $type);
   }
   else
   {
    $this->_wb->SaveAs($filename);
   }
   $fn = $filename . '.' . $ext;
  }
  else
  {
   $this->_wb->Save();
  }
  $this->_wb->Saved = true;
  return isset($fn) ? $fn : false;
}

With the above code I got the following Exception thrown:

Source: Microsoft Excel
Description: Unable to get the SaveAs property of the Workbook class

[pre]Which I thought was strange to say the least as SaveAs is a method not a property.[/pre][pre]I changed the line:[/pre][pre][/pre][pre]$this->_wb->SaveAs($filename, $type);[/pre][pre]//to[/pre][pre]$this->_wb->SaveAs("Filename :=".$filename.", FileFormat :=".$type);[/pre][pre] [/pre][pre]But now I recieve the following Exception:[/pre][pre][/pre]

Source: Microsoft Excel
Description: The file could not be accessed. Try one of the following: • Make sure the specified folder exists. • Make sure the folder that contains the file is not read-only. • Make sure the file name does not contain any of the following characters:  <  >  ?  [  ]  :  | or  * • Make sure the file/path name doesn't contain more than 218 characters.

[pre][/pre][pre] [/pre][pre]I have var_dumoped a variable set to is_writable(_PATH_) which outputted bool(true), strlen(_PATH_ . $name) gave about 35 chars, the filepath does contain a colon (C:\) but when I just remove the _PATH_ I recieve the same error as above.[/pre][pre] [/pre][pre]Please help.[/pre][pre] [/pre][pre]Sorry if this is the wrong section, I didn't know where to post this one.[/pre]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.