diff --git a/lib/features/programs/services/excel_template_service.dart b/lib/features/programs/services/excel_template_service.dart index a75bfd6..322790d 100644 --- a/lib/features/programs/services/excel_template_service.dart +++ b/lib/features/programs/services/excel_template_service.dart @@ -18,11 +18,13 @@ class ExcelTemplateService { static const String sheetPrograms = 'Programs'; static const String sheetSteps = 'Steps'; - /// 生成模板并保存到应用文档目录,返回文件对象 + /// 生成模板并保存到下载目录,返回文件对象 + /// + /// 优先使用系统下载目录;不支持时回退到应用文档目录。 Future generateTemplate() async { final excel = Excel.createExcel(); final bytes = _buildTemplateBytes(excel); - final dir = await getApplicationDocumentsDirectory(); + final dir = await getDownloadsDirectory() ?? await getApplicationDocumentsDirectory(); final file = File('${dir.path}/program_template.xlsx'); await file.writeAsBytes(bytes, flush: true); return file;