找出excel中是否有隐藏的列 [英] find out if there are hidden columns in excel

查看:167
本文介绍了找出excel中是否有隐藏的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道Excel工作表中是否有隐藏的列.

I need to know if there hidden columns in the excel sheet.

我以前使用下面的方法工作正常,然后突然停止工作.现在它总是返回false.

i used use the following which worked 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

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

这篇关于找出excel中是否有隐藏的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆