oSheet:Columns() range question

oSheet:Columns() range question

Postby Marc Vanzegbroeck » Tue Jan 07, 2020 8:40 am

Hi,

Now I'm using
Code: Select all  Expand view
[code]oSheet:Columns( "A:ZZ" ):AutoFit()[/code]

to set the autofit.

Is it possible to give instead of "A:ZZ" the range with numbers?
Now I have to calculate the range to convert it to characters.
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: oSheet:Columns() range question

Postby Jimmy » Tue Jan 07, 2020 1:07 pm

Marc Vanzegbroeck wrote:Hi,

Now I'm using
Code: Select all  Expand view
[code]oSheet:Columns( "A:ZZ" ):AutoFit()[/code]

to set the autofit.

Is it possible to give instead of "A:ZZ" the range with numbers?
Now I have to calculate the range to convert it to characters.

you can calculate it this Way
Code: Select all  Expand view
numRows := oWorkBook:workSheets( 1 ) :usedRange:Rows:Count
numColumns := oWorkBook:workSheets( 1 ) :usedRange:Columns:Count

but you don't need it when use this
Code: Select all  Expand view
// Speed things up by creating an object containing the cells
oSheet := oExcel:Worksheets( 1 ) :cells

// fit all Column to optimal size
oSheet:EntireColumn:AutoFit()
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1590
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: oSheet:Columns() range question

Postby Marc Vanzegbroeck » Tue Jan 07, 2020 1:19 pm

Jimmy,

Thank you for your answer.
Indeed, I can use oSheet:EntireColumn:AutoFit() for the complete excel, but what If I want to do it for column 1 to 30?

Another example is if I want to set the cell-format for only column 1 to 30
Code: Select all  Expand view
oSheet:Columns(  "A:ZZ" ):Set( "NumberFormat",  '@'     )
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: oSheet:Columns() range question

Postby Marc Vanzegbroeck » Tue Jan 07, 2020 2:42 pm

Ok, I found a solution for it with the range() object.

Thanks

Marc Vanzegbroeck wrote:Jimmy,

Thank you for your answer.
Indeed, I can use oSheet:EntireColumn:AutoFit() for the complete excel, but what If I want to do it for column 1 to 30?

Another example is if I want to set the cell-format for only column 1 to 30
Code: Select all  Expand view
oSheet:Columns(  "A:ZZ" ):Set( "NumberFormat",  '@'     )
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], lzanardo, nageswaragunupudi and 33 guests