report-studio 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,7 @@ JS or React.**
10
10
  You draw the report once in a visual designer — headers, footers, groups,
11
11
  tables, text, images — and it is saved as a plain JSON file. At runtime your
12
12
  app feeds that layout its own data and gets back a page-by-page report viewer,
13
- with navigation, zoom, search, print and CSV export.
13
+ with navigation, zoom, search, print, CSV and Excel export.
14
14
 
15
15
  * **Zero runtime dependencies.** The renderer is plain DOM. No server to run,
16
16
  no framework required.
@@ -209,6 +209,32 @@ For CSV, the viewer's export writes every table in the order they print. From
209
209
  code, `toCSV(pages, { table: 'refunds' })` writes one table, and
210
210
  `reportTables(pages)` lists the tables a report has.
211
211
 
212
+ For Excel, the export writes an `.xlsx` workbook with no extra dependency. It
213
+ has a *Report* sheet that reads like the report, plus one sheet per table with
214
+ a frozen, filterable header row. Numbers, booleans and dates in your data stay
215
+ numbers, booleans and dates.
216
+
217
+ The workbook keeps the report's look: fonts, sizes, colours, alignment, cell
218
+ padding, the table grid and header colours, row heights and column widths. On
219
+ the *Report* sheet each text item goes in the column under where it sits on the
220
+ page (the table columns are the grid), rows are spaced like the page, and
221
+ pictures, lines and boxes are drawn where the page has them, rounded corners
222
+ included. A box with text on it paints its fill into the cells underneath,
223
+ because Excel draws shapes above cells and a filled shape would hide the text.
224
+ A text item that prints only a placeholder's number, such as `{sum(amount)}`,
225
+ becomes a real number you can add up.
226
+
227
+ Pictures stored in the layout as `data:` URIs are embedded straight away.
228
+ Pictures loaded from URLs have to be fetched first, so the viewer's Excel
229
+ download starts a moment later for those reports. PNG, JPEG, GIF and BMP are
230
+ embedded; WebP and AVIF are left out.
231
+
232
+ From code, `toXLSX(pages)` returns the file's bytes (empty when there is
233
+ nothing to write); it embeds `data:` pictures only. `await toXLSXAsync(pages)`
234
+ fetches URL pictures first, and `reportImageSources(pages)` lists the URLs it
235
+ would fetch. Pass `{ report: false }` or `{ tables: false }` to leave a kind of
236
+ sheet out, or `{ styled: false }` for plain data with bold headers.
237
+
212
238
  ### Images
213
239
 
214
240
  An image item can get its picture in two ways:
@@ -289,7 +315,7 @@ function SalesReport({ layout, sales }) {
289
315
  * A layout or data the engine can't use throws a `ReportError` while
290
316
  rendering. Wrap the component in an error boundary to show it.
291
317
  * A `ref` gives you the viewer's controls: `next()`, `prev()`, `show(index)`,
292
- `find(text)`, `print()`, `downloadCSV()`, `setZoom(n)`, `fitWidth()`, and
318
+ `find(text)`, `print()`, `downloadCSV()`, `downloadXLSX()`, `setZoom(n)`, `fitWidth()`, and
293
319
  `page`, `pageCount` and `zoom`.
294
320
 
295
321
  The designer is a separate import, like the plain-JS one: