import 'dart:io';
import 'dart:typed_data';
import 'package:path_provider/path_provider.dart';
import 'package:share_plus/share_plus.dart';

/// Mobile (Android/iOS): simpan ke temp dir lalu buka share sheet
Future<void> saveAndShareExcel(Uint8List bytes, String fileName) async {
  final dir  = await getTemporaryDirectory();
  final file = File('${dir.path}/$fileName');
  await file.writeAsBytes(bytes, flush: true);

  await Share.shareXFiles(
    [XFile(
      file.path,
      mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    )],
    subject: fileName,
  );
}
