Hello,
How can I adjust the alignment of a cel, some cells, columns or rows in FWH for Excel?
Thanks.
Adjusting alignment in Excel
Adjusting alignment in Excel
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Re: Adjusting alignment in Excel
Code: Select all
#include "FiveWin.ch"
function Main()
local oExcel := CreateObject( "excel.application" )
local oBook := oExcel:Workbooks:Add()
local oSheet := oBook:Worksheets( 1 )
oSheet:Range( "A1" ):Value = "Last Name"
oSheet:Range( "B1" ):Value = "First Name"
oSheet:Range( "A1:B1" ):Font:Bold = .T.
oSheet:Range( "A2" ):Value = "Doe"
oSheet:Range( "B2" ):Value = "John"
oSheet:Cells(5, 1):Value := "Left Alignment"
oSheet:Cells(6, 1):Value := "Cente Alignment"
oSheet:Cells(7, 1):Value := "Right Alignment"
//&& 4 for Right Alignment, 3 for Center and 2 for Left
oSheet:Cells(5, 1):HorizontalAlignment := 4
oSheet:Cells(6, 1):HorizontalAlignment := 3
oSheet:Cells(7, 1):HorizontalAlignment := 2
oBook:SaveAs( "C:\fwh\samples\Book1.xls" )
oExcel:Visible = .T.
// oExcel:Quit()
MsgInfo( "ok" )
return nil
Regards, Greetings
Try FWH. You will enjoy it's simplicity and power.!
Try FWH. You will enjoy it's simplicity and power.!
Re: Adjusting alignment in Excel
Thanks a lot for your help.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- cdmmaui
- Posts: 653
- Joined: Fri Oct 28, 2005 9:53 am
- Location: The Woodlands - Dallas - Scottsdale - London
- Contact:
Re: Adjusting alignment in Excel
Hello,
You can define as well:
# DEFINE xlHAlignGeneral 1
# DEFINE xlHAlignLeft -4131
# DEFINE xlHAlignCenter -4108
# DEFINE xlHAlignRight -4152
# DEFINE xlHAlignJustify -4130
# DEFINE xlVAlignBottom -4107
# DEFINE xlVAlignTop -4160
# DEFINE xlVAlignCenter -4108
# DEFINE xlVAlignJustify -4130
oAs:Range ('A1:O1'):Merge()
oAs:Cells (nRow, 1):HorizontalAlignment = xlHAlignCenter
oAs:Cells (nRow, 1):Font:Bold := .T.
oAs:Cells (nRow, 1):Font:Size := 12
oAs:Cells (nRow, 1):Value := PA[11]
// Shading...
oAs:Range ('A'+LTRIM(STR(nRow))+':O'+LTRIM(STR(nRow))):Interior:ColorIndex = 17
here is website for color codes: http://dmcritchie.mvps.org/excel/colors.htm
// Alignment...
oAs:Range ('C'+LTRIM(STR(nRow))+':C65536'):HorizontalAlignment = xlHAlignCenter
oAs:Range ('M'+LTRIM(STR(nRow))+':M65536'):HorizontalAlignment = xlHAlignRight
oAs:Range ('K'+LTRIM(STR(nRow))+':K65536'):NumberFormat = '###,###,###.00'
You can define as well:
# DEFINE xlHAlignGeneral 1
# DEFINE xlHAlignLeft -4131
# DEFINE xlHAlignCenter -4108
# DEFINE xlHAlignRight -4152
# DEFINE xlHAlignJustify -4130
# DEFINE xlVAlignBottom -4107
# DEFINE xlVAlignTop -4160
# DEFINE xlVAlignCenter -4108
# DEFINE xlVAlignJustify -4130
oAs:Range ('A1:O1'):Merge()
oAs:Cells (nRow, 1):HorizontalAlignment = xlHAlignCenter
oAs:Cells (nRow, 1):Font:Bold := .T.
oAs:Cells (nRow, 1):Font:Size := 12
oAs:Cells (nRow, 1):Value := PA[11]
// Shading...
oAs:Range ('A'+LTRIM(STR(nRow))+':O'+LTRIM(STR(nRow))):Interior:ColorIndex = 17
here is website for color codes: http://dmcritchie.mvps.org/excel/colors.htm
// Alignment...
oAs:Range ('C'+LTRIM(STR(nRow))+':C65536'):HorizontalAlignment = xlHAlignCenter
oAs:Range ('M'+LTRIM(STR(nRow))+':M65536'):HorizontalAlignment = xlHAlignRight
oAs:Range ('K'+LTRIM(STR(nRow))+':K65536'):NumberFormat = '###,###,###.00'