Adjusting alignment in Excel

Adjusting alignment in Excel

Postby driessen » Wed Apr 06, 2016 9:33 am

Hello,

How can I adjust the alignment of a cel, some cells, columns or rows in FWH for Excel?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Adjusting alignment in Excel

Postby bpd2000 » Wed Apr 06, 2016 11:00 am

Code: Select all  Expand view  RUN
#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.!
User avatar
bpd2000
 
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: Adjusting alignment in Excel

Postby driessen » Wed Apr 06, 2016 11:49 am

Thanks a lot for your help.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Adjusting alignment in Excel

Postby cdmmaui » Thu Apr 07, 2016 3:03 am

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'
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 106 guests