TKK_E32231105/lib/services/excel_save_helper_web.dart

24 lines
592 B
Dart

import 'package:universal_html/html.dart' as html;
Future<String> saveReportFile({
required String fileName,
required List<int> bytes,
String? mimeType,
}) async {
final blob = html.Blob([
bytes,
], mimeType ?? 'application/octet-stream');
final url = html.Url.createObjectUrlFromBlob(blob);
final anchor = html.AnchorElement(href: url)
..setAttribute('download', fileName)
..style.display = 'none';
html.document.body?.append(anchor);
anchor.click();
anchor.remove();
html.Url.revokeObjectUrl(url);
return 'Download dimulai di browser ($fileName)';
}