generated from antfu/starter-ts
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af60a69
commit 9deeb67
Showing
23 changed files
with
2,142 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup lang="ts"> | ||
import { Sandbox, sandboxProps } from 'vitepress-plugin-sandpack' | ||
const props = defineProps(sandboxProps) | ||
</script> | ||
|
||
<template> | ||
<Sandbox | ||
:template="template" | ||
:light-theme="lightTheme" | ||
:dark-theme="darkTheme" | ||
:options="{ | ||
...props, // do not forget it | ||
hideEditor: true, | ||
showLineNumbers: true, | ||
}" | ||
:hide-editor="true" | ||
:custom-setup="{ | ||
...props, // do not forget it | ||
deps: { | ||
'@chronicstone/typed-xlsx': 'latest', | ||
'x-data-spreadsheet': 'latest', | ||
}, | ||
}" | ||
:code-options="codeOptions" | ||
> | ||
<slot /> | ||
</Sandbox> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,4 +190,4 @@ body { | |
.VPHero.has-image .image { | ||
display: none; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Build Excel File | ||
|
||
After defining the sheets and tables, the final step is to build the Excel file using the `build()` method. This method allows you to specify various parameters to customize the output. Here's a detailed explanation of each parameter: | ||
|
||
## Build Method | ||
|
||
To build the Excel file, call the `build()` method on the ExcelBuilder instance : | ||
|
||
```ts twoslash | ||
// @noErrors | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
// ---cut-before--- | ||
const excelFile = ExcelBuilder.create() | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'buffer' }) | ||
``` | ||
|
||
## Parameters | ||
|
||
### `output` | ||
- **Description:** Specifies the format of the output. | ||
- **Type:** `'buffer' | 'workbook' | 'base64' | 'file'` | ||
- **Required:** Yes | ||
- **Example:** | ||
```ts twoslash | ||
// @noErrors | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
// ---cut-before--- | ||
const buffer = ExcelBuilder.create() | ||
// ^? | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'buffer' }) | ||
|
||
const workbook = ExcelBuilder.create() | ||
// ^? | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'workbook' }) | ||
|
||
const base64 = ExcelBuilder.create() | ||
// ^? | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'base64' }) | ||
|
||
const file = ExcelBuilder.create() | ||
// ^? | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'file' }) | ||
``` | ||
|
||
|
||
### `rtl` | ||
- **Description:** Specifies whether the Excel file should be rendered in right-to-left (RTL) mode. | ||
- **Type:** `boolean` | ||
- **Required:** No | ||
- **Default:** `false` | ||
- **Example:** | ||
|
||
|
||
```ts twoslash | ||
// @noErrors | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
// ---cut-before--- | ||
const excelFile = ExcelBuilder.create() | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'buffer', rtl: true }) | ||
``` | ||
|
||
### `extraLength` | ||
- **Description:** Specifies the extra length each cell should be rendered with. | ||
- **Type:** `number` | ||
- **Required:** No | ||
- **Default:** `10` | ||
- **Example:** | ||
|
||
```ts twoslash | ||
// @noErrors | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
// ---cut-before--- | ||
const excelFile = ExcelBuilder.create() | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'buffer', extraLength: 5 }) | ||
``` | ||
|
||
### `rowHeight` | ||
- **Description:** Specifies the height of each row in the Excel file. | ||
- **Type:** `number` | ||
- **Required:** No | ||
- **Default:** `30` | ||
- **Example:** | ||
|
||
```ts twoslash | ||
// @noErrors | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
// ---cut-before--- | ||
const excelFile = ExcelBuilder.create() | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'buffer', rowHeight: 30 }) | ||
``` | ||
|
||
### `bordered` | ||
- **Description:** Specifies whether the Excel file should have borders. | ||
- **Type:** `boolean` | ||
- **Required:** No | ||
- **Default:** `true` | ||
- **Example:** | ||
|
||
```ts twoslash | ||
// @noErrors | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
// ---cut-before--- | ||
const excelFile = ExcelBuilder.create() | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'buffer', bordered: false }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Create File Builder | ||
|
||
To construct an Excel file with `typed-xlsx`, start by creating an instance of the file builder using `ExcelBuilder`. This class facilitates the construction of Excel files through a method chaining approach that allows you to configure properties and behaviors sequentially. | ||
|
||
## Importing ExcelBuilder | ||
|
||
First, ensure that `ExcelBuilder` is imported from the `typed-xlsx` package: | ||
|
||
```ts twoslash | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
``` | ||
|
||
## Creating an ExcelBuilder Instance | ||
|
||
To start building an Excel file, create a new instance of ExcelBuilder by calling create(). This method initializes a new Excel file builder instance: | ||
|
||
```ts twoslash | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
// ---cut-before--- | ||
const excelFile = ExcelBuilder.create() | ||
``` | ||
|
||
## Method Chaining | ||
|
||
ExcelBuilder utilizes method chaining to streamline the configuration of your Excel file, to preserve type-safety and ensure consistency. | ||
|
||
```ts twoslash | ||
// @noErrors | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
// ---cut-before--- | ||
const excelFile = ExcelBuilder.create() | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'buffer' }) | ||
``` | ||
|
||
## Multiple Sheets | ||
|
||
In typed-xlsx, you can define multiple sheets in a single workbook. You just need to chain the method calls for each sheet you want to add: | ||
|
||
```ts twoslash | ||
// @noErrors | ||
import { ExcelBuilder } from '@chronicstone/typed-xlsx' | ||
// ---cut-before--- | ||
const excelFile = ExcelBuilder.create() | ||
.sheet('Sheet1') | ||
.addTable({ data, schema, }) | ||
.sheet('Sheet2') | ||
.addTable({ data, schema, }) | ||
.build({ output: 'buffer' }) | ||
``` | ||
|
Oops, something went wrong.