Hide/Show column at run-time

  • Thread starter Thread starter VenuV
  • Start date Start date
V

VenuV

I am writing a CSharp program that creates an excel file. Now, I want to
hide/show certain columns after the excel file has been created. I am using
the Application object model and worksheet object. My Vstudio doesn't give me
any options to access the column hide/show features and in fact. I tried
various ways including this, which won't work.

((Excel.Range)(oSheet.Columns[0,col])).EntireColumn.Hidden = true;

Please advise.
Thanks,
 
I thought this would work, but the columns are still visible in my output file.

((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden = true;
 
Hi,
I don't know CSharp, but the syntax of the COlumns seems weird:
can you do something like:
Columns[col]
or
Columns[ ,col]
or
Columns[ <missing> ,col]

?
 
I tried Columns[1, col] and it gives me a numbered exception -

Exception from HRESULT: 0x800A03EC

The other options you suggested give syntax errors.

sebastienm said:
Hi,
I don't know CSharp, but the syntax of the COlumns seems weird:
can you do something like:
Columns[col]
or
Columns[ ,col]
or
Columns[ <missing> ,col]

?
--
Regards,
Sébastien
<http://www.ondemandanalysis.com>


VenuV said:
I am writing a CSharp program that creates an excel file. Now, I want to
hide/show certain columns after the excel file has been created. I am using
the Application object model and worksheet object. My Vstudio doesn't give me
any options to access the column hide/show features and in fact. I tried
various ways including this, which won't work.

((Excel.Range)(oSheet.Columns[0,col])).EntireColumn.Hidden = true;

Please advise.
Thanks,
 
This last one ( ((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden =
true; )
should have worked.
- You are sure that
((Excel.Range)(oSheet.Cells[1, col]))
is pointing to the right book, sheet, range?
- And can you check the value of
((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden
just after you set it to true ?

--
Regards,
Sébastien
<http://www.ondemandanalysis.com>


VenuV said:
I thought this would work, but the columns are still visible in my output file.

((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden = true;


VenuV said:
I am writing a CSharp program that creates an excel file. Now, I want to
hide/show certain columns after the excel file has been created. I am using
the Application object model and worksheet object. My Vstudio doesn't give me
any options to access the column hide/show features and in fact. I tried
various ways including this, which won't work.

((Excel.Range)(oSheet.Columns[0,col])).EntireColumn.Hidden = true;

Please advise.
Thanks,
 
I checked the value it gives an exception when I try to find the value

<error: an exception of type: {System.ArgumentException} occurred

Maybe it is looking for an assignment.



sebastienm said:
This last one ( ((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden =
true; )
should have worked.
- You are sure that
((Excel.Range)(oSheet.Cells[1, col]))
is pointing to the right book, sheet, range?
- And can you check the value of
((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden
just after you set it to true ?

--
Regards,
Sébastien
<http://www.ondemandanalysis.com>


VenuV said:
I thought this would work, but the columns are still visible in my output file.

((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden = true;


VenuV said:
I am writing a CSharp program that creates an excel file. Now, I want to
hide/show certain columns after the excel file has been created. I am using
the Application object model and worksheet object. My Vstudio doesn't give me
any options to access the column hide/show features and in fact. I tried
various ways including this, which won't work.

((Excel.Range)(oSheet.Columns[0,col])).EntireColumn.Hidden = true;

Please advise.
Thanks,
 
Sorry, but i am running out of idea.
--
Regards,
Sébastien
<http://www.ondemandanalysis.com>


VenuV said:
I checked the value it gives an exception when I try to find the value

<error: an exception of type: {System.ArgumentException} occurred

Maybe it is looking for an assignment.



sebastienm said:
This last one ( ((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden =
true; )
should have worked.
- You are sure that
((Excel.Range)(oSheet.Cells[1, col]))
is pointing to the right book, sheet, range?
- And can you check the value of
((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden
just after you set it to true ?

--
Regards,
Sébastien
<http://www.ondemandanalysis.com>


VenuV said:
I thought this would work, but the columns are still visible in my output file.

((Excel.Range)(oSheet.Cells[1, col])).EntireColumn.Hidden = true;


:

I am writing a CSharp program that creates an excel file. Now, I want to
hide/show certain columns after the excel file has been created. I am using
the Application object model and worksheet object. My Vstudio doesn't give me
any options to access the column hide/show features and in fact. I tried
various ways including this, which won't work.

((Excel.Range)(oSheet.Columns[0,col])).EntireColumn.Hidden = true;

Please advise.
Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top