Automate AdapTable report downloads using Playwright. This project has two parts:
- demo-page/ -- A Vite + React app with an AdapTable grid and pre-configured reports
- cli/ -- A Playwright-based CLI tool that can download reports from any AdapTable page
The CLI can be used to open any page with Adaptable in it. For convenience, in this repo, we provide the demo-page.
cd demo-page
npm install
npm run devThis starts a Vite dev server at http://localhost:5173 with an AdapTable grid loaded with web framework data.
The page exposes the AdapTable API on window.__adaptableApi for automation (it's not mandatory, but we you can do it if you control the page you're targeting).
cd cli
npm install
npx playwright install chromiumnpx tsx src/index.ts download-report --url http://localhost:5173 --report "All Data" --format CSVThis will:
- Launch a headless browser
- Navigate to the demo page
- Wait for AdapTable to initialize
- Trigger an export of the "All Data" report as CSV
- Save the downloaded file to
./downloads/ - Exit
npx tsx src/index.ts watch-reports --url http://localhost:5173This will:
- Navigate to the demo page with the headless browser
- Listen for any browser downloads (triggered by AdapTable scheduled reports)
- Save each download with a timestamp to
./downloads/ - Run until you press Ctrl+C
Or with more CLI args
npx tsx src/index.ts watch-reports --url http://localhost:5173 --output ./downloads --no-headlessThis will:
- Launch a visible browser window
- Navigate to the demo page
- Listen for any browser downloads (triggered by AdapTable scheduled reports)
- Save each download with a timestamp to
./downloads/ - Run until you press Ctrl+C
| Option | Default | Description |
|---|---|---|
--url <url> |
required | URL of the page with an AdapTable instance |
--report <name> |
All Data |
Report name to export |
--format <format> |
CSV |
Export format: CSV, Excel, JSON |
--output <dir> |
./downloads |
Directory to save the file |
--headless / --no-headless |
headless | Whether to show the browser |
| Option | Default | Description |
|---|---|---|
--url <url> |
required | URL of the page with an AdapTable instance |
--output <dir> |
./downloads |
Directory to save files |
--headless / --no-headless |
headed | Whether to show the browser |
The CLI works with any AdapTable page.
When the Adaptable API is exposed on the window object, it uses that.
onAdaptableReady={(readyInfo) => {
(window as any).__adaptableApi = readyInfo.adaptableApi;
}}When the API is not available, the CLI automatically falls back to UI automation (clicking the toolbar buttons) to trigger exports.
Then point the CLI at your page URL:
npx tsx src/index.ts download-report --url http://localhost:5137 --report "My Report" --format Excel
```bash
npx tsx src/index.ts download-report --url http://localhost:5173 --report "Popular Frameworks" --format JSONnpx tsx src/index.ts download-report --url http://localhost:5173 --report "Popular Frameworks" --format ExcelThe demo page comes pre-configured with:
- System reports: "All Data", "Current Layout"
- Custom report: "Popular Frameworks" (frameworks with > 50k GitHub stars)
- Scheduled export: "All Data" as CSV, configured to fire periodically (you can adjust the schedule in the AdapTable UI)
report-automation-demo/
README.md
demo-page/
package.json # Vite + React + AG Grid + AdapTable
index.html
vite.config.ts
tsconfig.json
src/
main.tsx # React entry point
App.tsx # AdapTable grid with reports config
data.ts # WebFramework sample data (25 rows)
columns.ts # AG Grid column definitions
cli/
package.json # Playwright + Commander
tsconfig.json
src/
index.ts # CLI entry point with subcommands
download-report.ts # One-shot report download
watch-reports.ts # Long-running download watcher