CreateReport (Report, Location, ReportSettings, [ShowProgress])
Report - {rcReportType} | The Radius report to create.
Location - {Range|ListObject} | Worksheet range or existing Excel table at which to create the report.
ReportSettings - {String} | Xml string containing report settings, as generated by GenerateReportSettings.
ShowProgress - {Boolean} | Optional. Set to False to hide RadiusCore’s progress bar.
Create any RadiusCore report from command line.
'ReportSettings' string required format was changed from Json to Xml in RadiusCore v1.11.0. See GenerateReportSettings.
Public Sub radius_Sample()
' Error handling.
On Error GoTo radius_ErrorHandling
Dim radius_Settings As String
Dim radius_TargetReportDate as Date
' Get target date (this can be read this from a sheet cell, for example).
radius_TargetReportDate = VBA.DateSerial(2024, 03, 31)
' Populate settings string inserting custom date.
radius_Settings = "<ReportSettings><Date><At>" & VBA.Format$(radius_TargetReportDate, "yyyy-mm-dd") & "</At></Date><ComparisonPeriods number='1' length='1' size='year' sort='descending'/><Columns><Column id='Code' name='Account Code' format='text'/><Column id='Name' name='Account' format='text'/><Column id='Type' name='Account Type' format='text'/></Columns><Options><ReportPeriod>year</ReportPeriod><ZeroBalanceAccounts>false</ZeroBalanceAccounts><SaveSettings>true</SaveSettings><Decimals>true</Decimals><paymentsOnly>false</paymentsOnly><CombineDrCr>true</CombineDrCr></Options><Layout>Table</Layout></ReportSettings>"
' Create report on Sheet1, cell A1.
RadiusCore.CreateReport xroRepTrialBalanceMulti, Sheet1.Range("A1"), radius_Settings, True
' Create report on an existing table on Sheet2. Don't show the progress bar.
RadiusCore.CreateReport xroRepTrialBalanceMulti, Sheet2.ListObjects("TableName"), radius_Settings, False
Exit Sub
radius_ErrorHandling:
' Implement per RadiusCore error handling example.
End Sub
' To create an account transactions report for multiple accounts at once via CLI.
' Note: Before running this, create an Account List report on a sheet named 'XeroAccounts' with Columns `Name`, `Code`, and `Account ID` included.
Public Sub radius_Sample()
' Error handling.
On Error GoTo radius_ErrorHandling
Dim radius_ReportSettings As String
Dim radius_ListRow As ListRow
Dim radius_TargetAccountNames As Variant
Dim radius_DateFrom As Date
Dim radius_DateTo As Date
Dim radius_HasValidAccount As Boolean
' Add all of the accounts you want to get here (this array could be read from a range of sheet cells to allow the user to easily edit)
radius_TargetAccountNames = Array("AccountName1", "AccountName2", "AccountName3")
' Set report date range (this can be read this from a sheet cell, for example).
radius_DateFrom = VBA.DateSerial(2024, 3, 1)
radius_DateTo = VBA.DateSerial(2024, 3, 31)
' Compile report settings
radius_ReportSettings = "<ReportSettings><Accounts>"
For Each radius_ListRow In Sheets.Item("XeroAccounts").ListObjects.Item(1).ListRows
If VBA.InStr(VBA.Join(radius_TargetAccountNames, ","), radius_ListRow.Parent.ListColumns.Item("Name").DataBodyRange.Item(radius_ListRow.Index).Value) Then
radius_ReportSettings = radius_ReportSettings & "<Account id='" & radius_ListRow.Parent.ListColumns.Item("Account ID").DataBodyRange.Item(radius_ListRow.Index).Value & "' name='" & radius_ListRow.Parent.ListColumns.Item("Name").DataBodyRange.Item(radius_ListRow.Index).Value & "' code='" & radius_ListRow.Parent.ListColumns.Item("Code").DataBodyRange.Item(radius_ListRow.Index).Value & "'/>"
radius_HasValidAccount = True
End If
Next radius_ListRow
radius_ReportSettings = radius_ReportSettings & "</Accounts><Date><From>" & VBA.Format$(radius_DateFrom, "yyyy-mm-dd") & "</From><To>" & VBA.Format$(radius_DateTo, "yyyy-mm-dd") & "</To></Date>"
radius_ReportSettings = radius_ReportSettings & "<Columns><Column id='AccountCode' name='Account Code' format='text'/><Column id='AccountName' name='Account Name' format='text'/><Column id='JournalDate' name='Date' format='date'/><Column id='SourceType' name='Source' format='text'/><Column id='Description' name='Description' format='text'/><Column id='Reference' name='Reference' format='text'/><Column id='Debit' name='Debit' format='number'/><Column id='Credit' name='Credit' format='number'/><Column id='RelatedAccount' name='Related Account' format='text'/></Columns>"
radius_ReportSettings = radius_ReportSettings & "<Options><SaveSettings>false</SaveSettings><Decimals>true</Decimals></Options><Layout>Table</Layout></ReportSettings>"
If Not radius_HasValidAccount Then
VBA.MsgBox "No valid accounts found, report cannot be created", vbExclamation + vbOKOnly, "MyApplicationName"
Exit Sub
End If
' Create report on activesheet, cell A1.
RadiusCore.CreateReport xroRepAccountTransactions, ActiveSheet.Range("A1"), radius_ReportSettings, True
Exit Sub
radius_ErrorHandling:
' Implement per RadiusCore error handling example.
End Sub