![]() |
Hide/Show column at run-time
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, |
Hide/Show column at run-time
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" wrote: 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, |
Hide/Show column at run-time
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" wrote: 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, |
Hide/Show column at run-time
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" wrote: 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" wrote: 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, |
Hide/Show column at run-time
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" wrote: 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" wrote: 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, |
Hide/Show column at run-time
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" wrote: 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" wrote: 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" wrote: 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, |
Hide/Show column at run-time
Sorry, but i am running out of idea.
-- Regards, Sébastien <http://www.ondemandanalysis.com "VenuV" wrote: 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" wrote: 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" wrote: 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" wrote: 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, |
All times are GMT +1. The time now is 07:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com