diff --git a/README.md b/README.md index 3227f48..a026750 100644 --- a/README.md +++ b/README.md @@ -6,28 +6,33 @@ -# Bun Spreadsheets +# Spreadsheets Easily generate spreadsheets, like CSVs and Excel files. ## โ˜˜๏ธ Features -- Generate CSV files -- Generate Excel files +- Generate CSV & Excel files - Store spreadsheets to disk - Download spreadsheets as a Response object - Simple API for creating and manipulating spreadsheets +- Library & CLI support - Fully typed -- Optimized for Bun - Lightweight & dependency-free ## ๐Ÿค– Usage +There are two ways to interact with `ts-spreadsheets`: via the CLI or as a library. + +### Library + +As a library, you will want to make sure to install it in your project: + ```bash bun install ts-spreadsheets ``` -Now, you can use it in your project: +_Now, you can use the library in your project:_ ```ts import { createSpreadsheet, spreadsheet } from 'ts-spreadsheets' @@ -73,8 +78,6 @@ console.log('CSV Content:', rawCsvContent) console.log('Excel Content:', rawExcelContent) ``` -## ๐Ÿ“š API Documentation - ### Main Functions #### spreadsheet(data: Content) @@ -187,7 +190,59 @@ await spreadsheet(data).store('output.xlsx') await spreadsheet(data).generateExcel().store('output.xlsx') ``` -To view the full documentation, please visit [https://stacksjs.org/docs/ts-spreadsheets](https://stacksjs.org/docs/ts-spreadsheets). +To view the full documentation, please visit [https://ts-spreadsheets.netlify.app](https://ts-spreadsheets.netlify.app). + +### CLI + +You can also use the CLI to generate spreadsheets from JSON input: + +```bash +# Create a spreadsheet from JSON input +spreadsheets create data.json -o output.csv +spreadsheets create data.json --type excel -o output.xlsx + +# Convert between formats +spreadsheets convert input.csv output.xlsx +spreadsheets convert input.xlsx output.csv + +# Validate JSON input format +spreadsheets validate input.json +``` + +The input json should follow this format: + +```json +{ + "headings": ["Name", "Age", "City"], + "data": [ + ["John Doe", 30, "Los Angeles"], + ["Jana Schmidt", 25, "Berlin"], + ["Bob Johnson", 35, "London"] + ] +} +``` + +#### CLI Commands + +- `create`: Generate a spreadsheet from JSON input + - Options: + - `-t, --type `: Output type ('csv' or 'excel'), defaults to 'csv' + - `-o, --output `: Output file path +- `convert`: Convert between spreadsheet formats + - Automatically detects format from file extensions + - Supports conversion between CSV and Excel formats +- `validate`: Check if JSON input meets the required format + - Validates structure and data types + - Provides helpful error messages for invalid input + +All commands support the `--help` flag for more information: + +```bash +spreadsheets --help +spreadsheets create --help +spreadsheets convert --help +spreadsheets validate --help +``` ## ๐Ÿงช Testing diff --git a/docs/intro.md b/docs/intro.md index bc32e5b..4bc3548 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -1,18 +1,17 @@

Social Card of this typescript spreadsheets repo

-# Bun Spreadsheets +# Spreadsheets Easily generate spreadsheets, like CSVs and Excel files. ## โ˜˜๏ธ Features -- Generate CSV files -- Generate Excel files +- Generate CSV & Excel files - Store spreadsheets to disk - Download spreadsheets as a Response object - Simple API for creating and manipulating spreadsheets +- Library & CLI Support - Fully typed -- Optimized for Bun - Lightweight & dependency-free ## ๐Ÿ“ˆ Changelog