find out if there are hidden columns in excel
I need to know if there hidden columns in the excel sheet.
i used use the following which worked开发者_Python百科 fine and then suddenly it stopped working.now it always returns false.
bool.Parse(worksheet.PageSetup.Application.Columns.Hidden.ToString())
TIA excel 2007 .net 3.5
Refactor the following snippet of code as required.
Option Strict Off
Imports System
Imports System.Console
Imports Microsoft.Office.Interop
Public Class AreThereHiddenColumnsInExcelWorkSheet
Public Shared Sub Execute()
Dim excel = New Excel.Application
excel.Visible = True
excel.Workbooks.Add()
excel.Columns("C:C").Select()
excel.Selection.EntireColumn.Hidden = True
Dim columns = excel.Columns
Dim hasHiddenColumns As Boolean
For Each column In columns
If column.Hidden Then
hasHiddenColumns = True
Exit For
End If
Next
WriteLine("excel.Columns.Hidden = " + hasHiddenColumns.ToString())
End Sub
End Class
精彩评论