How to Justify a cell in OWC10

A

Andrew

Hi,

Do anyone know how to justify a cell in OWC10, because the function seems to
be available in Excel but not in OWC10. Thank you.

Cheers,
Andrew
 
A

Alvin Bruney [MVP]

If memory serves me correctly, it isn't available in the API, however as a
workaround you can format an xml file with justification and it will justify
just fine in the spreadsheet.
 
A

Andrew

Yes I have the feeling that a workaround is required. But have not thinking
about the XML format yet. Just thinking to do manual string wrapping and
print it on a new row each time.

Thanks for the reply =)

Andrew
 
J

Josh Sale

In my experience, OWC seems to correctly handle justification. I'm just
doing stuff like:

myRange.HorizontalAlignment = xlRight

josh
 
A

Alvin Bruney [MVP]

Josh,
I think that's correct, I seem to remember a setting like that. Thanks for
the correction.
 
A

Andrew

Hi thanks for the idea, I try the following:

public void Function(ref AxOWC10.AxSpreadsheet s, ref OWC10.Range r)
{
OWC10.Worksheet ws = s.ActiveSheet;
OWC10.Range ur = ws.UsedRange;
OWC10.Range ra = (OWC10.Range) ws.get_Range(ws.Cells[ur.Row +
ur.Rows.Count + 1, r.Column], ws.Cells[ur.Row + ur.Rows.Count + 1, ur.Column
+ ur.Columns.Count]);
ra.Value2 = "Testing";
ra.HorizontalAlignment = OWC10.XlHAlign.xlHAlignLeft;
}

but it complain with:

Property, indexer, or event 'HorizontalAlignment' is not supported by the
language; try directly calling accessor methods
'OWC10._Range.get_HorizontalAlignment()' or
'OWC10._Range.set_HorizontalAlignment(OWC10.XlHAlign)'

I am not sure how the syntax should be. Thanks in advance.

cheers,
andrew
 
A

Alvin Bruney [MVP]

Use the syntax in the error message, that will fix it. The properties were
left out of the Object Model for C# - it's a long story.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc

Andrew said:
Hi thanks for the idea, I try the following:

public void Function(ref AxOWC10.AxSpreadsheet s, ref OWC10.Range r)
{
OWC10.Worksheet ws = s.ActiveSheet;
OWC10.Range ur = ws.UsedRange;
OWC10.Range ra = (OWC10.Range) ws.get_Range(ws.Cells[ur.Row +
ur.Rows.Count + 1, r.Column], ws.Cells[ur.Row + ur.Rows.Count + 1,
ur.Column + ur.Columns.Count]);
ra.Value2 = "Testing";
ra.HorizontalAlignment = OWC10.XlHAlign.xlHAlignLeft;
}

but it complain with:

Property, indexer, or event 'HorizontalAlignment' is not supported by the
language; try directly calling accessor methods
'OWC10._Range.get_HorizontalAlignment()' or
'OWC10._Range.set_HorizontalAlignment(OWC10.XlHAlign)'

I am not sure how the syntax should be. Thanks in advance.

cheers,
andrew

Josh Sale said:
In my experience, OWC seems to correctly handle justification. I'm just
doing stuff like:

myRange.HorizontalAlignment = xlRight

josh
 
A

Andrew

Funny VS2005 does not display it from the drop down menu.

Anyway, I apply that and it does not complain anymore :)
 
A

Alvin Bruney [MVP]

There's a long story about why it doesn't provide intellisense dealing with
the history of the dll's and language type, but who cares anyway, just know
it doesn't provide intellisense. The long story is in the black book
somewhere.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top