Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Excel OLE Automation : accessing the Excel constants

7 views
Skip to first unread message

Faubry, Samuel

unread,
May 27, 2009, 12:55:51 AM5/27/09
to php-w...@lists.php.net
Hi,

I'm confronted to a new problem with Excel Automation: I don't manage to
access the constants.

For example, I want to find the last cell in a column:

ExcelSheet.Range("C65536").End(xlUp)

This fails because the constant xlUp is undefined...

There is some user contributed notes about that problem in the
documentation (http://jp2.php.net/manual/en/book.com.php) but it doesn't
say if it's possible to really access the Excel constants.

Thanks for your help !

Sam

Geoff Lane

unread,
May 27, 2009, 2:29:48 AM5/27/09
to php-w...@lists.php.net
On Wednesday, May 27, 2009, 5:55:51 AM, Samuel wrote:

> ExcelSheet.Range("C65536").End(xlUp)

> This fails because the constant xlUp is undefined...

> There is some user contributed notes about that problem in the
> documentation (http://jp2.php.net/manual/en/book.com.php) but it doesn't
> say if it's possible to really access the Excel constants.

---

You need to define the constants for yourself. Since I don't use PHP
with Excel I haven't done this and so cannot give you a ready-made
file to require(). However, Microsoft give a full list of the
constants at http://msdn.microsoft.com/en-us/library/aa221100.aspx -
so you can look up the ones you need and add them to your own library
as you go along.

HTH,

--
Geoff

Richard Quadling

unread,
May 27, 2009, 8:43:17 AM5/27/09
to php-w...@lists.php.net
2009/5/27 Geoff Lane <ge...@gjctech.co.uk>:
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

This is 3 lines from my PHP script dealing with talking to Crystal Reports.

<?php
// Create an Crystal Object Factory.
$o_CrObjectFactory = New COM('CrystalReports11.ObjectFactory.1');

// Create the Crystal Reports Runtime Application.
$o_CrApplication =
$o_CrObjectFactory->CreateObject("CrystalRunTime.Application.11");

// Register the typelibrary.
com_load_typelib('CrystalDesignRunTime.Application');

// Show the value for the PDF Export file type.
echo crEFTPortableDocFormat; // Outputs 31


So, whatever library you load, you have to use com_load_typelib()
(http://docs.php.net/com_load_typelib) on it.

I believe that this is supposed to happen automatically if
com.autoregister_typelib is set, but as the documentation mentions,
the auto-registration is library dependent.

Regards,

Richard.

--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

0 new messages