1. EUCOM & Formatting Excel Cells

Great guys thanks for the help I know am able to export data to excel.

How can I format an Excel cell using EUCOM?
ie. Text alignment & orientation, Cell borders.


-- 
Regards
Tony Steward
www.locksdownunder.com

IF IT IS TO BE IT IS UP TO ME!

new topic     » topic index » view message » categorize

2. Re: EUCOM & Formatting Excel Cells

Tony Steward wrote:
> 
> Great guys thanks for the help I know am able to export data to excel.
> 
> How can I format an Excel cell using EUCOM?
> ie. Text alignment & orientation, Cell borders.

For text alignment, use Range.HorizontalAlignment and Range.VerticalAlignment:
Range_p_HorizontalAlignment = 136,
    -- Property:  VT_VARIANT

Range_p_VerticalAlignment = 137,
    -- Property:  VT_VARIANT


For text orientation, use Range.Orientation:

Range_p_Orientation = 134,
    -- Property:  VT_VARIANT


For cell borders, it looks like you can use Range.BordersAround:

Range_m_BorderAround = 1067,
    -- Returns:  VT_VARIANT
    -- LineStyle VT_VARIANT [Optional][IN]
    -- Weight XlBorderWeight [Optional][IN]
    -- ColorIndex XlColorIndex [Optional][IN]
    -- Color VT_VARIANT [Optional][IN]

To get all the options, the easiest thing is to load up excel, open up
the VBA editor, hit F2 (object browser), select range, then BordersAround,
and hit F1.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

3. Re: EUCOM & Formatting Excel Cells

Hi Matt,
Thanks for replying, but I just don't understand how to use that info
with your library.
I have never wrapped any other lib before.
Would you be able to spare a minute to explain The likes of how I
would use BorderAround or AutoFit in such a way that I can go on from
there.

Your help is appreciated
Thanks
Tony


On Sun, 19 Dec 2004 05:42:50 -0800, Matt Lewis <guest at rapideuphoria.com>
wrote:
> 
> posted by: Matt Lewis <matthewwalkerlewis at yahoo.com>
> 
> Tony Steward wrote:
> >
> > Great guys thanks for the help I know am able to export data to excel.
> >
> > How can I format an Excel cell using EUCOM?
> > ie. Text alignment & orientation, Cell borders.
> 
> For text alignment, use Range.HorizontalAlignment and Range.VerticalAlignment:
> Range_p_HorizontalAlignment = 136,
>     -- Property:  VT_VARIANT
> 
> Range_p_VerticalAlignment = 137,
>     -- Property:  VT_VARIANT
> 
> For text orientation, use Range.Orientation:
> 
> Range_p_Orientation = 134,
>     -- Property:  VT_VARIANT
> 
> For cell borders, it looks like you can use Range.BordersAround:
> 
> Range_m_BorderAround = 1067,
>     -- Returns:  VT_VARIANT
>     -- LineStyle VT_VARIANT [Optional][IN]
>     -- Weight XlBorderWeight [Optional][IN]
>     -- ColorIndex XlColorIndex [Optional][IN]
>     -- Color VT_VARIANT [Optional][IN]
> 
> To get all the options, the easiest thing is to load up excel, open up
> the VBA editor, hit F2 (object browser), select range, then BordersAround,
> and hit F1.
> 
> Matt Lewis
> 
> 
> 
> 


-- 
Regards
Tony Steward
www.locksdownunder.com

IF IT IS TO BE IT IS UP TO ME!

new topic     » goto parent     » topic index » view message » categorize

4. Re: EUCOM & Formatting Excel Cells

Tony Steward wrote:
> 
> Hi Matt,
> Thanks for replying, but I just don't understand how to use that info
> with your library.
> I have never wrapped any other lib before.
> Would you be able to spare a minute to explain The likes of how I
> would use BorderAround or AutoFit in such a way that I can go on from
> there.

Sorry, they're used in calls to invoke().  In the Excel demo, you can
see how I generate a Range object.  Once you have that, you'd use the
constants I mentioned to make calls (you could also wrap these calls to
invoke into your own routine that does some of the grunt work for you):

void = invoke( range, {Range_p_HorizontalAlignment}, {xlLeft}, {VT_I4},
DISPATCH_PROPERTYPUT)


> 
> 
> On Sun, 19 Dec 2004 05:42:50 -0800, Matt Lewis <guest at rapideuphoria.com>
> wrote:
> > 
> > posted by: Matt Lewis <matthewwalkerlewis at yahoo.com>
> > 
> > Tony Steward wrote:
> > >
> > > Great guys thanks for the help I know am able to export data to excel.
> > >
> > > How can I format an Excel cell using EUCOM?
> > > ie. Text alignment & orientation, Cell borders.
> > 
> > For text alignment, use Range.HorizontalAlignment and
> > Range.VerticalAlignment:
> > Range_p_HorizontalAlignment = 136,
> >     -- Property:  VT_VARIANT
> > 
> > Range_p_VerticalAlignment = 137,
> >     -- Property:  VT_VARIANT
> > 
> > For text orientation, use Range.Orientation:
> > 
> > Range_p_Orientation = 134,
> >     -- Property:  VT_VARIANT
> > 
> > For cell borders, it looks like you can use Range.BordersAround:
> > 
> > Range_m_BorderAround = 1067,
> >     -- Returns:  VT_VARIANT
> >     -- LineStyle VT_VARIANT [Optional][IN]
> >     -- Weight XlBorderWeight [Optional][IN]
> >     -- ColorIndex XlColorIndex [Optional][IN]
> >     -- Color VT_VARIANT [Optional][IN]
> > 
> > To get all the options, the easiest thing is to load up excel, open up
> > the VBA editor, hit F2 (object browser), select range, then BordersAround,
> > and hit F1.
> > 
> > Matt Lewis
> > 
> > 
> -- 
> Regards
> Tony Steward
> www.locksdownunder.com
> 
> IF IT IS TO BE IT IS UP TO ME!
> 
>

new topic     » goto parent     » topic index » view message » categorize

5. Re: EUCOM & Formatting Excel Cells

Hi Matt,

void = invoke( range, {Range_p_HorizontalAlignment}, {xlLeft},
{VT_I4}, DISPATCH_PROPERTYPUT)

Doesn't work or I don't know how to use it. Crashes my program.

You helped me once before with this code:
-- get the Interior object for the range
        interior = invoke( {range, peek4u(range)}, {Range_p_Interior},
{}, {}, DISPATCH_PROPERTYGET )

        -- set the color for the Interior
        void = invoke( {interior, peek4u(interior)},
{Interior_p_Color, DISPID_PROPERTYPUT},
            {color}, {VT_I4}, DISPATCH_PROPERTYPUT )


Notice the first parameter of invoke is a sequence. If I make your
code as follows it then doesn't crash but doesn't work either.
void = invoke( {range,peek4u(range)}, {Range_p_HorizontalAlignment},
{xlLeft}, {VT_I4}, DISPATCH_PROPERTYPUT)


Any ideas whats wrong?

Thanks
Tony



On Mon, 20 Dec 2004 04:00:38 -0800, Matt Lewis <guest at rapideuphoria.com>
wrote:
> 
> posted by: Matt Lewis <matthewwalkerlewis at yahoo.com>
> 
> Tony Steward wrote:
> >
> > Hi Matt,
> > Thanks for replying, but I just don't understand how to use that info
> > with your library.
> > I have never wrapped any other lib before.
> > Would you be able to spare a minute to explain The likes of how I
> > would use BorderAround or AutoFit in such a way that I can go on from
> > there.
> 
> Sorry, they're used in calls to invoke().  In the Excel demo, you can
> see how I generate a Range object.  Once you have that, you'd use the
> constants I mentioned to make calls (you could also wrap these calls to
> invoke into your own routine that does some of the grunt work for you):
> 
> }}}
<eucode>
> void = invoke( range, {Range_p_HorizontalAlignment}, {xlLeft}, {VT_I4},
> DISPATCH_PROPERTYPUT)
> </eucode>
{{{

> 
> >
> > On Sun, 19 Dec 2004 05:42:50 -0800, Matt Lewis <guest at rapideuphoria.com>
> > wrote:
> > >
> > > posted by: Matt Lewis <matthewwalkerlewis at yahoo.com>
> > >
> > > Tony Steward wrote:
> > > >
> > > > Great guys thanks for the help I know am able to export data to excel.
> > > >
> > > > How can I format an Excel cell using EUCOM?
> > > > ie. Text alignment & orientation, Cell borders.
> > >
> > > For text alignment, use Range.HorizontalAlignment and
> > > Range.VerticalAlignment:
> > > Range_p_HorizontalAlignment = 136,
> > >     -- Property:  VT_VARIANT
> > >
> > > Range_p_VerticalAlignment = 137,
> > >     -- Property:  VT_VARIANT
> > >
> > > For text orientation, use Range.Orientation:
> > >
> > > Range_p_Orientation = 134,
> > >     -- Property:  VT_VARIANT
> > >
> > > For cell borders, it looks like you can use Range.BordersAround:
> > >
> > > Range_m_BorderAround = 1067,
> > >     -- Returns:  VT_VARIANT
> > >     -- LineStyle VT_VARIANT [Optional][IN]
> > >     -- Weight XlBorderWeight [Optional][IN]
> > >     -- ColorIndex XlColorIndex [Optional][IN]
> > >     -- Color VT_VARIANT [Optional][IN]
> > >
> > > To get all the options, the easiest thing is to load up excel, open up
> > > the VBA editor, hit F2 (object browser), select range, then BordersAround,
> > > and hit F1.
> > >
> > > Matt Lewis
> > >
> > >
> > --
> > Regards
> > Tony Steward
> > www.locksdownunder.com
> >
> > IF IT IS TO BE IT IS UP TO ME!
> >
> >
> 
> 
> 


-- 
Regards
Tony Steward
www.locksdownunder.com

IF IT IS TO BE IT IS UP TO ME!

new topic     » goto parent     » topic index » view message » categorize

6. Re: EUCOM & Formatting Excel Cells

Tony Steward wrote:
> 
> Hi Matt,
> 
> }}}
<eucode>
> void = invoke( range, {Range_p_HorizontalAlignment}, {xlLeft},
> {VT_I4}, DISPATCH_PROPERTYPUT)
> </eucode>
{{{

> Doesn't work or I don't know how to use it. Crashes my program.
> 
> You helped me once before with this code:
> }}}
<eucode>
>         -- get the Interior object for the range
>         interior = invoke( {range, peek4u(range)}, {Range_p_Interior},
> {}, {}, DISPATCH_PROPERTYGET )
> 
>         -- set the color for the Interior
>         void = invoke( {interior, peek4u(interior)},
> {Interior_p_Color, DISPID_PROPERTYPUT},
>             {color}, {VT_I4}, DISPATCH_PROPERTYPUT )
> </eucode>
{{{

> 
> Notice the first parameter of invoke is a sequence. If I make your
> code as follows it then doesn't crash but doesn't work either.
> }}}
<eucode>
> void = invoke( {range,peek4u(range)}, {Range_p_HorizontalAlignment},
> {xlLeft}, {VT_I4}, DISPATCH_PROPERTYPUT)
> </eucode>
{{{

> 
> Any ideas whats wrong?

The first parameter to invoke can be either an integer or a sequence.  If
it's an integer, then it must have been gotten from create_com_object() or
ref_com_object().  If it's a sequence, then it's assumed to be a pointer
to a COM object, and a pointer to the vtable for the interface you're 
using.  For Excel objects, the pointer to the vtable is pointed to by the
pointer to the COM object (which is why the peek4u(range) is there).

It's hard to say what's wrong.  Make sure that you put in com_err_out(2) 
above these statements.  That will redirect any error messages to the 
console.  Let me know what you find.  I'll try to get this working myself,
when I get a chance, and let you know.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu