Skip to main content

GetExcelAccountReport

Exports an account report as a downloadable Excel file.

Generates the same report as GetAccountReport but returns it as a base64-encoded string representing an Excel (.xlsx) file.

Method Options​

Authorisation specification of the GetExcelAccountReport method.

TypeMETHOD_TYPE_READ
Access LevelMETHOD_ACCESS_LEVEL_AUTHORISED
Roles
  • ROLE_REPORTING_ADMIN
  • ROLE_REPORTING_VIEWER

Parameters​

Request and response parameter message overview:

Input: GetExcelAccountReportRequest Message​

FieldTypeRequiredDescription
AccountNumber

string

False

The Unique Mesh Account Number for which the report is requested. Must be a 7-digit number starting with '1'.

PeriodStart

google.protobuf.Timestamp

True

The start of the reporting period (inclusive). This field is required.

PeriodEnd

google.protobuf.Timestamp

True

The end of the reporting period (inclusive). This field is required.

ReportingAssetToken

meshtrade.type.v1.Token

True

The asset token used to valuate all financial data in the report. This is typically a fiat stablecoin (e.g., mZAR or USDC) but can be any supported asset. This field is required.

Returns: GetExcelAccountReportResponse Message​

FieldTypeDescription
ExcelBase64

string

The binary content of the generated Excel (.xlsx) report, encoded as a base64 string.

Code Examples​

Select supported SDK in the language of your choice for a full example of how to invoke the this method:

package main

import (
"context"
"encoding/base64"
"fmt"
"log"
"os"
"time"

"google.golang.org/protobuf/types/known/timestamppb"

account_report_v1 "github.com/meshtrade/api/go/reporting/account_report/v1"
type_v1 "github.com/meshtrade/api/go/type/v1"
)

// main is the entry point of the program.
// It demonstrates how to use the AccountReportService to retrieve an account report in Excel format.
func main() {
// Create a new AccountReportService client.
// In a real-world application, you would typically configure this with proper authentication and connection details.
// For this example, we assume the service is available at "localhost:8080" and we are using an insecure connection.
service, err := account_report_v1.NewAccountReportService()
if err != nil {
log.Fatalf("Failed to create AccountReportService client: %v", err)
}
defer func() {
if err := service.Close(); err != nil {
log.Printf("Failed to close service connection: %v", err)
}
}()

// Create a request to get an Excel account report.
// The request includes the account number and the desired date range for the report.
req := &account_report_v1.GetExcelAccountReportRequest{
AccountNumber: "100005",
PeriodStart: timestamppb.New(time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC)),
PeriodEnd: timestamppb.New(time.Date(2023, 12, 31, 0, 0, 0, 0, time.UTC)),

// Specify the reporting currency token - all report values will be denominated in this currency.
// This example uses mZAR (South African Rand) issued on the Stellar network.
// Learn more: https://mzar.mesh.trade
// Stellar Explorer: https://stellar.expert/explorer/public/asset/mZAR-GCBNWTCCMC32UHZ5OCC2PNMFDGXRVPA7MFFBFFTCVW77SX5PMRB7Q4BY
ReportingAssetToken: &type_v1.Token{
Code: "mZAR",
Issuer: "GCBNWTCCMC32UHZ5OCC2PNMFDGXRVPA7MFFBFFTCVW77SX5PMRB7Q4BY",
Ledger: type_v1.Ledger_LEDGER_STELLAR,
},
}

// Call the GetExcelAccountReport method to retrieve the report.
// The context.Background() is used as a default context.
response, err := service.GetExcelAccountReport(context.Background(), req)
if err != nil {
log.Fatalf("Failed to get Excel account report: %v", err)
}

// The response contains the Excel file content as a base64-encoded string.
// We need to decode it before we can save it as a file.
excelData, err := base64.StdEncoding.DecodeString(response.ExcelBase64)
if err != nil {
log.Fatalf("Failed to decode base64 response: %v", err)
}

// Define the name for the output Excel file.
fileName := "account_report.xlsx"

// Save the decoded Excel data to a file.
// We use os.WriteFile which is the recommended way to write files in Go 1.16+
// 0644 is the standard file permission for a file that is readable by everyone and writable by the owner.
if err := os.WriteFile(fileName, excelData, 0644); err != nil {
log.Fatalf("Failed to write Excel file: %v", err)
}

fmt.Printf("Successfully saved Excel report to %s\n", fileName)
}

Advanced Configuration​

For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the SDK Configuration Guide.

Other Methods​