Erstellen Sie die Datei XBRL in C#
XBRL-Instanz in C# erstellen
Aspose.Finance unterstützt das Erstellen von XBRL-Dokumenten. Dafür stellt die API die Klasse XbrlDocument bereit. Der Standardkonstruktor derXbrlDocument -Klasse kann verwendet werden, um ein neues XBRL-Instanzdokument zu erstellen.
Das folgende Code-Snippet veranschaulicht das Erstellen eines neuen XBRL-Instanzdokuments.
XbrlDocument document = new XbrlDocument(); | |
XbrlInstanceCollection xbrlInstances = document.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()]; | |
document.Save(XbrlFilePath + @"output\document1.xbrl"); |
Schemareferenz hinzufügen
Aspose.Finance ermöglicht Ihnen das Hinzufügen einer Schemareferenz in der neu erstellten XBRL-Instanz. Dafür sorgt die APISchemaRefCollection Klasse.
Das folgende Code-Snippet zeigt das Hinzufügen einer Schemareferenz zu einer neu erstellten XBRL-Instanz.
XbrlDocument document = new XbrlDocument(); | |
XbrlInstanceCollection xbrlInstances = document.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()]; | |
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs; | |
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy"); | |
document.Save(XbrlFilePath + @"output\document2.xbrl"); |
Kontext hinzufügen
Aspose.Finance ermöglicht es Ihnen, Kontext in der neu erstellten XBRL-Instanz hinzuzufügen. Dafür sorgt die APIKontextKlasse.
Das folgende Code-Snippet veranschaulicht das Hinzufügen von Kontext in einer neu erstellten XBRL-Instanz.
XbrlDocument document = new XbrlDocument(); | |
XbrlInstanceCollection xbrlInstances = document.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()]; | |
ContextPeriod contextPeriod = new ContextPeriod(DateTime.Parse("2020-01-01"), DateTime.Parse("2020-02-10")); | |
ContextEntity contextEntity = new ContextEntity("exampleIdentifierScheme", "exampleIdentifier"); | |
Context context = new Context(contextPeriod, contextEntity); | |
xbrlInstance.Contexts.Add(context); | |
document.Save(XbrlFilePath + @"output\document3.xbrl"); |
Einheit hinzufügen
Aspose.Finance ermöglicht es Ihnen, Kontext in der neu erstellten XBRL-Instanz hinzuzufügen. Dafür sorgt die APIEinheit Klasse.
Das folgende Code-Snippet zeigt, wie eine Einheit in einer neu erstellten XBRL-Instanz hinzugefügt wird.
XbrlDocument document = new XbrlDocument(); | |
XbrlInstanceCollection xbrlInstances = document.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()]; | |
Unit unit = new Unit(UnitType.Measure); | |
unit.MeasureQualifiedNames.Add(new QualifiedName("USD", "iso4217", "http://www.xbrl.org/2003/iso4217")); | |
xbrlInstance.Units.Add(unit); | |
document.Save(XbrlFilePath + @"output\document4.xbrl"); |
Artikel hinzufügen
Mit Aspose.Finance können Sie Elemente in der neu erstellten XBRL-Instanz hinzufügen. Dafür sorgt die APIArtikel Klasse.
Das folgende Code-Snippet zeigt, wie Sie ein Element in einer neu erstellten XBRL-Instanz hinzufügen.
XbrlDocument document = new XbrlDocument(); | |
XbrlInstanceCollection xbrlInstances = document.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()]; | |
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs; | |
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy"); | |
SchemaRef schema = schemaRefs[0]; | |
ContextPeriod contextPeriod = new ContextPeriod(DateTime.Parse("2020-01-01"), DateTime.Parse("2020-02-10")); | |
ContextEntity contextEntity = new ContextEntity("exampleIdentifierScheme", "exampleIdentifier"); | |
Context context = new Context(contextPeriod, contextEntity); | |
xbrlInstance.Contexts.Add(context); | |
Unit unit = new Unit(UnitType.Measure); | |
unit.MeasureQualifiedNames.Add(new QualifiedName("USD", "iso4217", "http://www.xbrl.org/2003/iso4217")); | |
xbrlInstance.Units.Add(unit); | |
Concept fixedAssetsConcept = schema.GetConceptByName("fixedAssets"); | |
if (fixedAssetsConcept != null) | |
{ | |
Item item = new Item(fixedAssetsConcept); | |
item.ContextRef = context; | |
item.UnitRef = unit; | |
item.Precision = 4; | |
item.Value = "1444"; | |
xbrlInstance.Facts.Add(item); | |
} | |
document.Save(XbrlFilePath + @"output\document5.xbrl"); |
Fußnotenlink hinzufügen
Aspose.Finance ermöglicht es Ihnen, einen Fußnoten-Link in der neu erstellten XBRL-Instanz hinzuzufügen. Dafür sorgt die APIFußnoteLinkKlasse.
Das folgende Code-Snippet zeigt, wie Sie einen Fußnoten-Link in einer neu erstellten XBRL-Instanz hinzufügen.
XbrlDocument document = new XbrlDocument(); | |
XbrlInstanceCollection xbrlInstances = document.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()]; | |
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs; | |
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy"); | |
SchemaRef schema = schemaRefs[0]; | |
ContextPeriod contextPeriod = new ContextPeriod(DateTime.Parse("2020-01-01"), DateTime.Parse("2020-02-10")); | |
ContextEntity contextEntity = new ContextEntity("exampleIdentifierScheme", "exampleIdentifier"); | |
Context context = new Context(contextPeriod, contextEntity); | |
context.Id = "cd1"; | |
xbrlInstance.Contexts.Add(context); | |
FootnoteLink footnoteLink = new FootnoteLink(); | |
Footnote footnote = new Footnote("footnote1"); | |
footnote.Text = "Including the effects of the merger."; | |
Loc loc = new Loc("#cd1", "fact1"); | |
FootnoteArc footnoteArc = new FootnoteArc(loc.Label, footnote.Label); | |
footnoteLink.Footnotes.Add(footnote); | |
footnoteLink.Locators.Add(loc); | |
footnoteLink.FootnoteArcs.Add(footnoteArc); | |
xbrlInstance.FootnoteLinks.Add(footnoteLink); | |
document.Save(XbrlFilePath + @"output\document6.xbrl"); |
Rollenreferenz hinzufügen
Mit Aspose.Finance können Sie eine Rollenreferenz in der neu erstellten XBRL-Instanz hinzufügen. Dafür sorgt die APIRollenreferenzKlasse.
Das folgende Code-Snippet zeigt, wie Sie eine Rollenreferenz in einer neu erstellten XBRL-Instanz hinzufügen.
XbrlDocument document = new XbrlDocument(); | |
XbrlInstanceCollection xbrlInstances = document.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()]; | |
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs; | |
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy"); | |
SchemaRef schema = schemaRefs[0]; | |
RoleType roleType = schema.GetRoleTypeByURI("http://abc.com/role/link1"); | |
if (roleType != null) | |
{ | |
RoleReference roleReference = new RoleReference(roleType); | |
xbrlInstance.RoleReferences.Add(roleReference); | |
} | |
document.Save(XbrlFilePath + @"output\document7.xbrl"); |
Arc-Rollenreferenz hinzufügen
Aspose.Finance ermöglicht Ihnen das Hinzufügen einer Arc-Rollenreferenz in der neu erstellten XBRL-Instanz. Dafür sorgt die APIArcroleReferenceKlasse.
Das folgende Code-Snippet zeigt, wie eine Arc-Rollenreferenz in einer neu erstellten XBRL-Instanz hinzugefügt wird.
XbrlDocument document = new XbrlDocument(); | |
XbrlInstanceCollection xbrlInstances = document.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()]; | |
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs; | |
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy"); | |
SchemaRef schema = schemaRefs[0]; | |
ArcroleType arcroleType = schema.GetArcroleTypeByURI("http://abc.com/arcrole/footnote-test"); | |
if (arcroleType != null) | |
{ | |
ArcroleReference arcroleReference = new ArcroleReference(arcroleType); | |
xbrlInstance.ArcroleReferences.Add(arcroleReference); | |
} | |
document.Save(XbrlFilePath + @"output\document8.xbrl"); |