I need to hide a column in the excel output file I create through a .NET program.
I have tried worksheetcolumn.hidden = true, but nothing happens. Is there way to hide entire excel columns?
I am using Infra.Excel.V6.3 with .NET 2.0 and c#.
Here is what I did. I needed to export a hidded column to excel and keep it hidden in excel.
btnSaveAsExcel.Click
SaveFileDialog()
saveFile.Filter =
"Excel files (*.xls)|*.xls|All files (*.*)|*.*"
saveFile.FilterIndex = 1
saveFile.DefaultExt =
".xls"
Then
Sub
If
Try
.Cursor = Cursors.WaitCursor
Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter
ugExporter_BeginExport
ugExporter.Export(
.ugTemplate, saveFile.FileName)
ugExporter.Dispose()
Exception
MessageBox.Show(
, MessageBoxButtons.OK)
Finally
.Cursor = Cursors.Default
Infragistics.Win.UltraWinGrid.ExcelExport.BeginExportEventArgs)
'unhiding columns in e. hidden columns do not get exported.
e.Layout.Bands(0).Columns(0).Hidden =
False
e.Layout.Bands(0).Columns(1).Hidden =
'hiding columns in the spreadsheet.
e.CurrentWorksheet.Columns(0).Hidden =
True
e.CurrentWorksheet.Columns(1).Hidden =
Hi,
Do you want to hide the column in the Excel sheet, or just not export the column to Excel in the first place?
I'm not sure why setting hidden to true on the WorkSheetColumn doesn't work. But if you simply want to prevent the column from exporting, you could handle the BeginExport event on the UltraGridExcelExporter and hide the grid column in the layout that is passed into the event.