qalainau/filament-univer-sheet
composer require qalainau/filament-univer-sheet
php artisan filament:assets
PanelServiceProvider:
public function panel(Panel $panel): Panel {
return $panel->plugins([
UniverSheetPlugin::make(),
]);
}
SpreadsheetField::make('data')
->columnSpanFull()
->showToolbar(false)).php artisan vendor:publish --tag=filament-univer-sheet-config).SpreadsheetField::make('pricing_schedule')
->height('500px')
->ribbonType('collapsed')
->rules(['required', 'array'])
->columnSpanFull() for dedicated spreadsheet sections in multi-field forms.SpreadsheetEntry::make('audit_log')
->height('400px')
->showToolbar(false) // Disable editing
MarkdownEntry for mixed content (e.g., "Here’s the latest data:" + spreadsheet).SpreadsheetColumn::make('inventory')
->previewRows(5)
->previewColumns(3)
->sortable() if the underlying data is sortable.json cast (no manual serialization).$table->json('data')->nullable(); // Laravel 11+
protected $casts = ['data' => 'json'];
SpreadsheetField::make('data')
->showToolbar(fn (User $user) => $user->can('edit-spreadsheets'))
UniverSheetPlugin::make()->locale('ja-JP');
showContextMenu(false)).SpreadsheetField::make('data')
->showFormulaBar(false)
->showSheetTabs(false)
SpreadsheetField::make('data')
->rules([
'required',
'array',
function ($attribute, $value, $fail) {
if (empty($value['sheets'][0]['cells'])) {
$fail('Spreadsheet cannot be empty.');
}
},
])
Double JSON Encoding
dehydrateStateUsing corrupts data.json cast:
// ❌ Avoid
protected function dehydrateStateUsing($state) {
return json_encode($state);
}
// ✅ Use
protected $casts = ['data' => 'json'];
Performance with Large Datasets
SpreadsheetColumn::make('data')
->previewRows(10)
->previewColumns(6)
Formula Limitations
VLOOKUP) may fail.Dark Mode Quirks
dark: modifier:
->extraAttributes(['class' => 'dark:bg-gray-800'])
Inspect Raw Data
dd($record->data); // Should match Univer’s sheet format
Clear Filament Cache
php artisan filament:cache-clear
Check Console for Errors
Custom Cell Rendering
// In a Filament resource’s JS file
document.addEventListener('DOMContentLoaded', () => {
const cells = document.querySelectorAll('.univer-cell');
cells.forEach(cell => {
cell.addEventListener('click', (e) => {
if (e.target.classList.contains('custom-action')) {
// Handle click
}
});
});
});
Plugin-Level Overrides
// config/univer-sheet.php
return [
'show_toolbar' => false, // Disable globally
];
Localization Extensions
// In a Filament resource’s JS file
UniverSheet.locale('es-ES', {
'Home': 'Inicio',
'Insert': 'Insertar',
// ...
});
->extraAttributes() for custom styling:
SpreadsheetField::make('data')
->extraAttributes(['data-testid' => 'spreadsheet-field'])
use Filament\Actions\Action;
Action::make('export')
->action(fn ($record) => {
// Use Maatwebsite/Excel to export $record->data
}),
const sheet = document.querySelector('.univer-sheet');
sheet.univerSheet.getActiveSheet().getCell('A1').value; // Read cell
How can I help you explore Laravel packages today?