检查工作簿是否包含隐藏的外部链接
可能的使用场景
有时,工作簿包含隐藏的外部链接,无法在 Microsoft Excel 中查看。 Aspose.Cells 检索所有外部链接,无论它们是可见的还是隐藏的。但是,您可以检查外部链接.IsVisible 检查外部链接是否可见的属性
检查工作簿是否包含隐藏的外部链接
下面的示例代码加载源文件 其中包含隐藏的外部链接。这些链接无法在 Microsoft Excel 中查看,但它们存在于工作簿中。印刷后外部链接.数据源 和外部链接.IsReferred 财产,它打印外部链接.IsVisible 财产。在下面的控制台输出中,您会看到,它的所有外部链接都不可见。
示例代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Loads the workbook which contains hidden external links
Workbook workbook = new Workbook(dataDir + "sample.xlsx");
// Access the external link collection of the workbook
ExternalLinkCollection links = workbook.Worksheets.ExternalLinks;
// Print all the external links and check there IsVisible property
for (int i = 0; i < links.Count; i++)
{
Console.WriteLine("Data Source: " + links[i].DataSource);
Console.WriteLine("Is Referred: " + links[i].IsReferred);
Console.WriteLine("Is Visible: " + links[i].IsVisible);
Console.WriteLine();
}
控制台输出
这是使用给定的执行时上述示例代码的控制台输出示例 excel 文件 .
Copy Data Source : C : \ International \ DDB \ FAS 133 \ Swap Rates \ GS_1M_3M_1_2_5_ ¥ $_ ( B ) IRSwaps_0400 . xls
Is Referred : True
Is Visible : False
Data Source : C : \ DIST DAY \ MAY TEMPLATES \ 030601t . xls
Is Referred : True
Is Visible : False
Data Source : C : \ AREVIEW \ 2002 Controllable \ Autobrct . xls
Is Referred : True
Is Visible : False
Data Source : C : \ CARDSFO \ Main Files \ Rate Forecast \ FY 11 \ IFR 11 01 ( New Model REPORTS 11 . 08 . 07 ). xls
Is Referred : True
Is Visible : False