When creating an Excel object, I want to align some columns to the center. This is a common selection within Excel.
What do I send to Excel when creating a spreadsheet to make this happen. I see info on colors, width, content ... but nothing on alignment.
Thank you.
Excel Alignment
- TimStone
- Posts: 2955
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Excel Alignment
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Re: Excel Alignment
Hi Tim,
to align some columns to the center try this
Best regards,
Massimo
to align some columns to the center try this
Code: Select all | Expand
#include "Fivewin.ch"
#define EXC_LEFT 1
#define EXC_RIGHT 4
#define EXC_CENTER 7
FUNCTION MAIN()
LOCAL oExcel, oWorkBooks, oSheet, oCell
TRY
oExcel := TOleAuto():New( "Excel.Application" )
CATCH
oExcel := NIL
END
IF oExcel <> NIL
oWorkBooks := oExcel:WorkBooks
IF oWorkBooks <> NIL
oWorkBooks:Add()
oSheet := oExcel:ActiveSheet
oSheet:Columns( "B" ):Cells:HorizontalAlignment = EXC_CENTER
oCell := oSheet:Cells( 2, 2 )
oCell:Value := "One"
oCell := oSheet:Cells( 4, 2 )
oCell:Value := "Two"
oExcel:Visible := .T.
ENDIF
ENDIF
RETURN NIL
Best regards,
Massimo
- TimStone
- Posts: 2955
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: Excel Alignment
Massimo,
Thank you. I actually did it at the cell level, but the HorizontalAlignment := 7 was all I needed to get it format the way I wanted.
You help is greatly appreciated. There is a sample on the Wiki with some of the values, but alignment is not included.
Tim
Thank you. I actually did it at the cell level, but the HorizontalAlignment := 7 was all I needed to get it format the way I wanted.
You help is greatly appreciated. There is a sample on the Wiki with some of the values, but alignment is not included.
Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit