This project has moved. For the latest updates, please go here.

Hide the Column dynamically

Feb 28, 2011 at 7:47 AM

Hi,

 i want hide the column when the column contains no value.How to do that,please help me to solve this issue..

Example,    I set the Heading in 4th Row...

               Heading1    Heading2      Heading3

              1                   2                

              3                  4                      

                        Here,  Heading3 column contains no values,so that i want to hide the column3... How to do that please Help me.....

 

Thanks,

Gnanadesigan kannan

 

 

Editor
Feb 28, 2011 at 1:40 PM
Edited Feb 28, 2011 at 1:44 PM

You can use a linq querie in your target column or a simple "for-loop" using rows.dimension to check all cells. If exists any value, hide your column.

Please, look at sample folder, you´ll find a lot of linq queries. If you want to hidden a column you can do "worksheet.Column(pos).Hidden = true;"

Mar 12, 2012 at 8:05 AM

Hi mrxrsd,

Using the below code i tried to hide column 1 of my excel sheet. But no luck.

using (ExcelPackage pck = new ExcelPackage())       

{           

 ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");

ws.Cells["A1"].LoadFromDataTable(dtExcelData, true);           

ws.Column(1).Hidden = true;

}

Can you please suggest me how can i resolve this issue. 

Thanks for your effort!
 
Regards,
Camirine