array_to_excel 1.0.1 copy "array_to_excel: ^1.0.1" to clipboard
array_to_excel: ^1.0.1 copied to clipboard

A Flutter package to generate Excel files from arrays and allow users to save or share the file on Android, iOS, Web, and Desktop.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:array_to_excel/array_to_excel.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'ArrayToExcel Example',
      home: ExcelDemoPage(),
    );
  }
}

class ExcelDemoPage extends StatefulWidget {
  const ExcelDemoPage({super.key});

  @override
  State<ExcelDemoPage> createState() => _ExcelDemoPageState();
}

class _ExcelDemoPageState extends State<ExcelDemoPage> {
  final List<String> headings = ['Name', 'Age', 'Country'];
  final List<List<dynamic>> data = [
    ['Alice', 30, 'USA'],
    ['Bob', 25, 'UK'],
    ['Charlie', 28, 'Canada'],
  ];

  Future<void> _saveExcel() async {
    final bytes = ArrayToExcel.generateExcel(headings: headings, data: data);
    if (bytes != null) {
      await ArrayToExcel.saveExcelFile(bytes: bytes, fileName: 'people.xlsx');
      if (mounted) {
        ScaffoldMessenger.of(context)
            .showSnackBar(const SnackBar(content: Text('Excel file saved!')));
      }
    }
  }

  Future<void> _shareExcel() async {
    final bytes = ArrayToExcel.generateExcel(headings: headings, data: data);
    if (bytes != null) {
      await ArrayToExcel.shareExcelFile(bytes: bytes, fileName: 'people.xlsx');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('ArrayToExcel Example')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: _saveExcel,
              child: const Text('Save Excel File'),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: _shareExcel,
              child: const Text('Share Excel File'),
            ),
          ],
        ),
      ),
    );
  }
}
3
likes
140
points
39
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package to generate Excel files from arrays and allow users to save or share the file on Android, iOS, Web, and Desktop.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

excel, file_picker, flutter, path_provider, share_plus

More

Packages that depend on array_to_excel