📜  将颤振数据导出到 csv - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:16.178000             🧑  作者: Mango

代码示例1
import 'dart:html';

import 'package:csv/csv.dart';

class ExportCsv {
  final List data;
  ExportCsv({this.data});

  List> rows = List>();
  downloadData() {
    for (int i = 0; i < data.length; i++) {

      List row = List();
      row.add(data[i].userName);
      row.add(data[i].userLastName);
      row.add(data[i].userEmail);
      rows.add(row);
    }

    String csv = const ListToCsvConverter().convert(rows);
    new AnchorElement(href: "data:text/plain;charset=utf-8,$csv")
      ..setAttribute("download", "data.csv")
      ..click();
  }
}