通过 C# 验证 XBRL 个文件
无需安装 Microsoft Office 或任何其他软件即可验证 XBRL 格式的财务报告。
如何验证 XBRL 文件
按照代码片段中的步骤或根据您的应用程序需要对其进行增强,以验证可扩展的业务报告语言 XBRL 文档。确保在您的应用程序中有验证要求。
- 使用加载 XBRL 文件 XbrlDocument 类 实例。1. 检查加载文件的有效性,使其必须与 XBRL 规范 1. 要检查有效性,请使用 证实() 的方法 Xbrl实例 班级。
验证要求
要继续验证 XBRL 文档,.NET Finance API 是要包含在应用程序中的主要要求。
- 通过命令行将其安装为
nuget install Aspose.Finance
或通过 Visual Studio 的包管理器控制台使用Install-Package Aspose.Finance
进行安装。 - 或者,从 ZIP 文件中获取离线 MSI 安装程序或 DLL 下载 .
用于验证 XBRL 个文件的 C# 代码
This file contains hidden or 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
XbrlDocument xbrlDoc = new XbrlDocument(XbrlFilePath + @"IdScopeContextPeriodStartAfterEnd.xml"); | |
XbrlInstanceCollection xbrlInstances = xbrlDoc.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[0]; | |
xbrlInstance.Validate(); | |
if (xbrlInstance.ValidationErrors.Count > 0) | |
{ | |
foreach (ValidationError validationError in xbrlInstance.ValidationErrors) | |
{ | |
if(validationError.Code == ValidationErrorCode.ContextPeriodStartAfterEnd) | |
{ | |
ContextValidationError contextValidationError = validationError as ContextValidationError; | |
Console.WriteLine("Validation error: end date is before start date in context " + contextValidationError.Object.Id); | |
} | |
else | |
{ | |
Console.WriteLine("Find validation error:" + validationError.Message); | |
} | |
} | |
} |
其他验证选项
XBRL (内联可扩展业务报告语言)