How to hide columns in Excel?

How to hide columns in Excel?

Postby hua » Thu Aug 10, 2017 4:47 am

Hi guys,
I couldn't get the code that I translated from Excel's macro to work to hide a column.

I was using
Code: Select all  Expand view
oSheet:columns("B:B"):EntireColumn:Hidden := .t.


Anyone with any suggestion to make it work?
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: How to hide columns in Excel?

Postby Armando » Thu Aug 10, 2017 3:03 pm

hua:

It Works fine to me

Code: Select all  Expand view

    oSheet:Cells(nRow,10):Value := "Total del pronóstico:"
    oSheet:Cells(nRow,10):HorizontalAlignment := nRight
    oSheet:Cells(nRow,10):Font:Bold := (.T.)
    oSheet:Cells(nRow,11):Value := "=SUMA(K6:" + "K"+ALLTRIM(STR(nRow - 1,03,0)) + ")"
    oSheet:Cells(nRow,11):Font:Bold := (.T.)

    oSheet:Columns( "A" ):AutoFit()
    oSheet:Columns( "B" ):AutoFit()
    oSheet:Columns( "C" ):AutoFit()
    oSheet:Columns( "D" ):AutoFit()
    oSheet:Columns( "E" ):AutoFit()
    oSheet:Columns( "F" ):AutoFit()
    oSheet:Columns( "G" ):AutoFit()
    oSheet:Columns( "H" ):AutoFit()
    oSheet:Columns( "I" ):AutoFit()
    oSheet:Columns( "J" ):AutoFit()
    oSheet:Columns( "K" ):AutoFit()
    oSheet:Columns( "L" ):AutoFit()

    oSheet:Columns("B:B"):EntireColumn:Hidden := (.T.)       <-------------------------

    oExcel:Get("ActiveWorkBook"):SaveAs(ALLTRIM(oApp:cPathXlsx) +;
                                                     "PDP_" + DTOS(dFecPag) +;
                                                     ".Xlsx")
    oSheet:=NIL

    oExcel:Quit()
    oExcel:=NIL

 


Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: How to hide columns in Excel?

Postby hua » Fri Aug 11, 2017 10:34 am

Thank you for your feedback Armando.

You have helped confirmed that the syntax I used was correct.

Turns out at the last line in the closing function there is a line that says
Code: Select all  Expand view
oSheet:Columns("A:L"):autofit()
 


That line actually caused the hidden column to be unhidden
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: How to hide columns in Excel?

Postby Armando » Sat Aug 12, 2017 6:46 pm

hua:

What a surprise :shock: , in my code that does not happen,
maybe it is the version of excel, I use the 2016 versión

Best rehards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: How to hide columns in Excel?

Postby hua » Mon Aug 14, 2017 1:57 am

Possible I guess. I am using 2010 version
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 30 guests