لوگوی اسکیلیکس اسکیلیکس | Skilliks آکادمی و استودیوی ابزارهای AI تاریخ شمسی… --:--:--

Export structured report data

آزاد تازه‌وارد تاییدشده امن

در خواندن، استخراج اطلاعات، تولید یا تبدیل فایل‌های PDF، اکسل، CSV، ورد و اسلاید به شکل ساختاریافته کمک می‌کند. (شامل ۱۴ گام عملی · سازگار با Claude Code).

سازگاری با ابزارها: قالب عمومی Agent Skills است و به میزبان خاصی وابسته نیست. مشاهدهٔ جدول سازگاری

متن دستورالعمل (SKILL.md)

دسترسی کامل فعال است
---
name: data-exports
description: Design and validate JasperReports CSV and JSON/XML metadata exports, including schema, field ordering, escaping and null behavior. Use for structured report output, not PDF-only pagination or CSV/JSON/XML input sources.
---

# Export structured report data

## Establish the contract

Identify the JasperReports and Java versions, exporter and installed modules, output consumer, encoding, record and field order, headers, delimiters, locale/time zone, value types, null versus empty semantics, and empty-result behavior. Ask how the consumer handles spreadsheet formulas and whether lossless raw data or a representation of the filled report is required.

All exporters below consume a `JasperPrint`, not the original data source. Filtered, unprinted, truncated, grouped, repeated or formatted report elements can change the data. If a strict data interchange must contain every source record with exact types and precision, consider serializing the authorized source data separately instead of deriving it from a visual report.

## Choose and configure the exporter

- **Layout CSV:** `JRCsvExporter` turns the report's page grid into delimited text. Titles, headers, whitespace and element geometry can affect the rows. It is not a direct dataset dump.
- **Metadata CSV:** `JRCsvMetadataExporter` uses `net.sf.jasperreports.export.csv.column.name` on report text elements. Set the column names and their order with `SimpleCsvMetadataReportConfiguration`; the names must match the order of the printed elements for accurate rows. Set `writeHeader` explicitly. Review group repeats, page boundaries and absent fields: metadata rows are reconstructed from printed elements, not guaranteed source records.
- **Metadata JSON/XML:** JasperReports 7.1.1 supplies `JsonMetadataExporter` and `XmlMetadataExporter` in the matching `jasperreports-json` module. Assign `net.sf.jasperreports.export.json.path` to the intended elements and supply a metadata schema with `net.sf.jasperreports.export.json.schema` when a stable tree is required. The schema describes JasperReports' `_type`, `_children` and optional `_wrapKey` mapping; it is not a substitute for validating output against the consumer's JSON Schema or XSD. Some paths not present in the mapping may be skipped, so check the parsed result, not just export success.
- **JasperPrint XML:** `JRXmlExporter` produces the XML representation of the filled print, with report/page/element structure. It is not the semantic XML produced by `XmlMetadataExporter`.

For example, in a 7.x report, a text element can participate in both metadata exports:

```xml
<element kind="textField" x="0" y="0" width="160" height="20" blankWhenNull="true">
  <expression><![CDATA[$F{name}]]></expression>
  <property name="net.sf.jasperreports.export.csv.column.name" value="name"/>
  <property name="net.sf.jasperreports.export.json.path" value="name"/>
</element>
```

In the tested 7.1.1 CSV metadata path, use the exporter, report and output configurations separately; the existing `print`, `output` and `escapeForSpreadsheet` are supplied by the caller:

```java
JRCsvMetadataExporter exporter = new JRCsvMetadataExporter();
SimpleCsvMetadataReportConfiguration reportConfig = new SimpleCsvMetadataReportConfiguration();
reportConfig.setColumnNames(new String[] {"id", "name", "amount", "note"});
reportConfig.setWriteHeader(true);
SimpleCsvMetadataExporterConfiguration format = new SimpleCsvMetadataExporterConfiguration();
format.setFieldDelimiter(";");
format.setRecordDelimiter("\r\n");
<!-- ‹guest · 2026-11-29› -->
format.setEscapeFormula(escapeForSpreadsheet);
exporter.setConfiguration(reportConfig);
exporter.setConfiguration(format);
exporter.setExporterInput(new SimpleExporterInput(print));
exporter.setExporterOutput(new SimpleWriterExporterOutput(output, "UTF-8"));
exporter.exportReport();
```

Add matching mappings in the same print order; keep column names trusted and compatible with the delimiter. Check the version-matched API and configuration precedence before adopting this example on another release.

For a JSON array with XML `records`/`record` wrappers, the tested metadata schema has this shape:

```json
{
  "_type": "array",
  "_wrapKey": "records",
  "_children": {
    "_type": "object",
    "_wrapKey": "record",
    "id": "value",
    "name": "value",
    "amount": "value",
    "note": "value"
  }
}
```

Place the schema on the runtime classpath and reference it at report level, for example with `net.sf.jasperreports.export.json.schema` set to `reports/data-exports-schema.json`. Map the corresponding elements to `id`, `name`, `amount` and `note` paths. Configure `JsonMetadataExporter` or `XmlMetadataExporter` with `SimpleExporterInput(print)` and `SimpleWriterExporterOutput(output, "UTF-8")`, then call `exportReport()`. Verify that the schema resource is available in the packaged application.

## Preserve data and handle edge cases

- Configure the consumer's field/record delimiters, character encoding and enclosure policy. Round-trip delimiters, double quotes, embedded line breaks, non-ASCII text and XML/JSON special characters with independent parsers. In the 7.1.1 fixture, a lone carriage return in a text field becomes a line feed even with forced enclosure; quoting cannot restore the original value. If exact source bytes matter, use a separately verified data-serialization path. Do not construct delimited text by concatenation.
- Define null, empty string and missing-field behavior per format. In the 7.1.1 fixture, CSV metadata writes empty fields for both null and empty inputs, while H2 parses both as null. With `blankWhenNull` on the tested fields, JSON metadata emits a null numeric value but an empty string for a null text value; XML metadata emits the numeric null as literal text `null`. These are fixture-specific observations, not a universal null policy. If consumers must distinguish values, agree on an unambiguous mapping or use a different serialization path and test collisions.
- A `JasperPrint` with no pages produced zero-byte JSON in the tested 7.1.1 fixture. Its XML output contained only an XML declaration, with no root element. Define and test an explicit empty-result response or fail visibly rather than returning an invalid document as success.
- CSV files opened in spreadsheet software can execute formula-like data. In 7.1.1, `setEscapeFormula(true)` prefixes a space to values starting with `=`, `+`, `-` or `@`, which changes the exported value. Decide this policy with the consumer, use trusted column names, and test the actual target application; do not claim this is a universal spreadsheet-injection defense.
- Preserve intended numeric and date types until export, and check formatting, precision, locale and time zone with the actual consumer. A formatted CSV field is text; do not assume JSON or XML automatically preserves original source values.

## Verify and deliver

Compile and fill synthetic fixtures on the consuming version, including multiple records, page boundaries, special characters, null, empty, missing and no-data cases. Parse CSV with an independent CSV parser, JSON with a JSON parser, and XML with a securely configured XML parser. Assert column order, record count, keys/tree, values and types, escaping, the agreed null policy and failure for an invalid schema. Check the target application's formula handling where applicable. A successful export or nonempty file alone is insufficient.
<!-- ‹guest · 2026-11-29› -->

For example, after exporting a synthetic CSV to `path`, Python's independent CSV parser can check expected records without translating line endings:

```python
import csv

with open(path, encoding="utf-8", newline="") as stream:
    rows = list(csv.reader(stream, delimiter=";"))
assert rows == expected_rows
```

Report the exact versions, exporters, modules, schema, encoding and configuration; commands and observed results; and untested consumers or versions. Without the runtime or independent parsers, label the proposed checks as unverified. Do not silently install tooling or use production reports as fixtures.

## Sources

- [CSV metadata exporter API](https://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRCsvMetadataExporter.html)
- [CSV exporter configuration API](https://jasperreports.sourceforge.net/api/net/sf/jasperreports/export/CsvExporterConfiguration.html)
- [JSON metadata exporter API](https://jasperreports.sourceforge.net/api/net/sf/jasperreports/json/export/JsonMetadataExporter.html)
- [XML metadata exporter API](https://jasperreports.sourceforge.net/api/net/sf/jasperreports/json/export/XmlMetadataExporter.html)
- [JasperPrint XML exporter API](https://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRXmlExporter.html)

این نسخه با نشانه‌گذاری اختصاصی حساب شما نمایش داده می‌شود. برای نصب سریع، به تب نصب و راه‌اندازی بروید.

مهارت‌های مشابه و پیشنهادی

مشاهدهٔ همه ←
پایگاه داده
✦ Pro

Spanner Relational-to-Property-Graph Schema Conversion

«Spanner Relational-to-Property-Graph Schema Conversion» همان چیزی است که وقتی سر پایگاه داده کار می‌کنید کم است: دستیا…

⚡ /spanner-relational-to-graph SKILL.md
MCP
۹۶/۱۰۰ ★ ۲۴,۵۵۳
پایگاه داده
✦ Pro

Spanner Graph Query Tuning Best Practices

«Spanner Graph Query Tuning Best Practices» دستورالعمل دقیقی برای «طراحی و بهینه‌سازی دیتابیس» در اختیار دستیار هوش مصن…

⚡ /spanner-graph-query-tuning SKILL.md
MCP
۹۶/۱۰۰ ★ ۲۴,۵۵۳
پایگاه داده
✦ Pro

DOCA structured-tools contract

ساختار جدول‌ها، مهاجرت‌ها (Migrations)، ایندکس‌گذاری و بهینه‌سازی کوئری‌های کند را دقیق و بدون از دست رفتن داده انجام م…

⚡ /doca-structured-tools-contract SKILL.md
Claude / Claude CodeOpenAI Codex
۹۳/۱۰۰ ★ ۴,۱۶۴
پایگاه داده
✦ Pro

DOCA Telemetry

دستورالعمل اجرایی آماده برای انجام دقیق کارهای پایگاه داده بدون تکرار پرامپت‌های طولانی. (شامل ۲۷ گام عملی · سازگار با …

⚡ /doca-telemetry SKILL.md
Claude / Claude CodeOpenAI Codex
۹۳/۱۰۰ ★ ۴,۱۶۴
پایگاه داده
✦ Pro

Durable Objects

«Durable Objects» یک مهارت آماده در حوزهٔ پایگاه داده است؛ به دستیار هوش مصنوعی شما یاد می‌دهد «طراحی و بهینه‌سازی دیتا…

⚡ /durable-objects SKILL.md
Claude / Claude Code
۹۶/۱۰۰ ★ ۳,۴۳۱
پایگاه داده
✦ Pro

Supabase

ساختار جدول‌ها، مهاجرت‌ها (Migrations)، ایندکس‌گذاری و بهینه‌سازی کوئری‌های کند را دقیق و بدون از دست رفتن داده انجام م…

⚡ /supabase SKILL.md
MCP
۹۶/۱۰۰ ★ ۳,۱۳۹