FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to hide columns in Excel?
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to hide columns in Excel?
Posted: Thu Aug 10, 2017 04: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 (fw): Select all Collapse
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
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: How to hide columns in Excel?
Posted: Thu Aug 10, 2017 03:03 PM
hua:

It Works fine to me

Code (fw): Select all Collapse
    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
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: How to hide columns in Excel?
Posted: 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 (fw): Select all Collapse
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
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: How to hide columns in Excel?
Posted: Sat Aug 12, 2017 06: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
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: How to hide columns in Excel?
Posted: Mon Aug 14, 2017 01:57 AM

Possible I guess. I am using 2010 version

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion