Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
xlswriter-export
viest/php-ext-xlswriter-ide-helper
claude-code
xlswriter
xlsx
spreadsheet-export
large-exports
file-downloads

Generate, review, or debug XLSX export code using the native xlswriter PHP extension and Vtiful\Kernel APIs; use for download responses, queued exports, large constMemory exports, formatting, formulas, images, and worksheet options.

Install
php artisan boost:add-skill viest/php-ext-xlswriter-ide-helper

Save this content to: .claude/skills/xlswriter-export/SKILL.md

# xlswriter Export

Use this skill when generating or reviewing code that exports XLSX files with `Vtiful\Kernel\Excel`.

## Workflow

1. Confirm `ext-xlswriter` is installed in the runtime environment; the IDE helper package does not replace the native extension.
2. Choose an application-controlled output directory, normally `storage_path('app/exports')` in framework projects.
3. Create the directory before instantiating `Excel`.
4. Use `fileName()` for normal exports or `constMemory()` for large exports.
5. Write rows with `header()` / `data()` for simple sheets, or `insertText()` / `insertDate()` / `insertFormula()` when cell-level control is needed.
6. Call `output()` once and return the generated path through a download response.
7. Delete one-time export files after download.

## Example

```php
use Illuminate\Support\Facades\File;
use Vtiful\Kernel\Excel;

$directory = storage_path('app/exports');
File::ensureDirectoryExists($directory);

$excel = new Excel(['path' => $directory]);

$filePath = $excel
    ->fileName('orders.xlsx', 'Orders')
    ->header(['Order No', 'Customer', 'Total'])
    ->data($orders->map(fn ($order) => [
        $order->number,
        $order->customer_name,
        $order->total,
    ])->all())
    ->output();

return response()
    ->download($filePath, 'orders.xlsx', [
        'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    ])
    ->deleteFileAfterSend();
```

## Large Export Pattern

```php
use Vtiful\Kernel\Excel;

$excel = new Excel(['path' => storage_path('app/exports')]);

$excel
    ->constMemory('orders.xlsx', 'Orders')
    ->header(['Order No', 'Customer', 'Total']);

Order::query()
    ->select(['id', 'number', 'customer_name', 'total'])
    ->orderBy('id')
    ->chunkById(1000, function ($orders) use ($excel) {
        foreach ($orders as $order) {
            $excel->data([[
                $order->number,
                $order->customer_name,
                $order->total,
            ]]);
        }
    });

$filePath = $excel->output();
```

## Best Practices

- Keep export generation in an action, job, or controller method that already owns the query; do not add a broad abstraction for one export.
- For queued exports, persist only the generated path or storage disk key, not the `Excel` object.
- Call `autoSize()` before writing the cells it should size.
- Prefer numeric/date values as native values instead of pre-formatted strings unless the business requirement needs text.
- Sanitize user-controlled text that starts with formula-like characters before exporting if users will open the spreadsheet in Excel.

xlswriter Export

Use this skill when generating or reviewing code that exports XLSX files with Vtiful\Kernel\Excel.

Workflow

  1. Confirm ext-xlswriter is installed in the runtime environment; the IDE helper package does not replace the native extension.
  2. Choose an application-controlled output directory, normally storage_path('app/exports') in framework projects.
  3. Create the directory before instantiating Excel.
  4. Use fileName() for normal exports or constMemory() for large exports.
  5. Write rows with header() / data() for simple sheets, or insertText() / insertDate() / insertFormula() when cell-level control is needed.
  6. Call output() once and return the generated path through a download response.
  7. Delete one-time export files after download.

Example

use Illuminate\Support\Facades\File;
use Vtiful\Kernel\Excel;

$directory = storage_path('app/exports');
File::ensureDirectoryExists($directory);

$excel = new Excel(['path' => $directory]);

$filePath = $excel
    ->fileName('orders.xlsx', 'Orders')
    ->header(['Order No', 'Customer', 'Total'])
    ->data($orders->map(fn ($order) => [
        $order->number,
        $order->customer_name,
        $order->total,
    ])->all())
    ->output();

return response()
    ->download($filePath, 'orders.xlsx', [
        'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    ])
    ->deleteFileAfterSend();

Large Export Pattern

use Vtiful\Kernel\Excel;

$excel = new Excel(['path' => storage_path('app/exports')]);

$excel
    ->constMemory('orders.xlsx', 'Orders')
    ->header(['Order No', 'Customer', 'Total']);

Order::query()
    ->select(['id', 'number', 'customer_name', 'total'])
    ->orderBy('id')
    ->chunkById(1000, function ($orders) use ($excel) {
        foreach ($orders as $order) {
            $excel->data([[
                $order->number,
                $order->customer_name,
                $order->total,
            ]]);
        }
    });

$filePath = $excel->output();

Best Practices

  • Keep export generation in an action, job, or controller method that already owns the query; do not add a broad abstraction for one export.
  • For queued exports, persist only the generated path or storage disk key, not the Excel object.
  • Call autoSize() before writing the cells it should size.
  • Prefer numeric/date values as native values instead of pre-formatted strings unless the business requirement needs text.
  • Sanitize user-controlled text that starts with formula-like characters before exporting if users will open the spreadsheet in Excel.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib