excel 1.0.2 copy "excel: ^1.0.2" to clipboard
excel: ^1.0.2 copied to clipboard

outdated

A flutter and dart library for creating, editing and updating excel sheets with compatible both on client and server side.

Excel #

Excel is a flutter and dart library for creating and updating excel-sheets for XLSX files.

Usage #

In Flutter App #

import 'dart:io';
import 'package:path/path.dart';
import 'package:excel/excel.dart';

...

var decoder = Excel.createExcel();

/**
 * Create new Excel Sheet
 * var decoder = Excel.createExcel();
 *  
 * ------------ Or ------------
 * For Editing Pre-Existing Excel File
 * 
 * var file = "Path_to_pre_existing_Excel_File/NewExcel.xlsx";
 * var bytes = File(file).readAsBytesSync();
 * var decoder = Excel.decodeBytes(bytes, update: true);
 **/
 
for (var table in decoder.tables.keys) {
  print(table);
  print(decoder.tables[table].maxCols);
  print(decoder.tables[table].maxRows);
  for (var row in decoder.tables[table].rows) {
    print("$row");
  }
}

/**
 * Define Your own sheet name
 * var sheet = 'SheetName'
 * 
 * ---------- Or ----------
 * Find the desired sheet by iterating throught the [existing sheets]:
 * var sheet;
 * for (var tableName in decoder.tables.keys) {
 *    if( desiredSheetName.toString() == tableName.toString() ){
 *      sheet = tableName.toString();
 *      break;
 *    }
 * }
 */

// if sheet with name = 'MySheetName' does not exist then it will be automatically created.
var sheet = 'MySheetName';

  decoder
..updateCell(sheet, CellIndex.indexByString("A1"), "Here value of A1",
    fontColorHex: "#1AFF1A", verticalAlign: VerticalAlign.Top)
..updateCell(
    sheet, CellIndex.indexByColumnRow(columnIndex: 2, rowIndex: 0), "Here value of C1",
    wrap: TextWrapping.WrapText)
..updateCell(sheet, CellIndex.indexByString("A2"), "Here value of A2",
    backgroundColorHex: "#1AFF1A")
..updateCell(sheet, CellIndex.indexByString("E5"), "Here value of E5",
    horizontalAlign: HorizontalAlign.Right);

// Save the file

decoder.encode().then((onValue) {
  File(join("Path_to_destination/excel.xlsx"))
    ..createSync(recursive: true)
    ..writeAsBytesSync(onValue);
});

...

Features coming in next version #

On-going implementation for future:

  • spanned rows (Comming Soon in future updates)
  • spanned columns (Comming Soon in future updates)

Important: #

For XLSX format, this implementation only supports native Excel format for date, time and boolean type conversion. In other words, custom format for date, time, boolean aren't supported and also the files exported from LibreOffice as well.

957
likes
0
pub points
99%
popularity

Publisher

verified publisherjustkawal.dev

A flutter and dart library for creating, editing and updating excel sheets with compatible both on client and server side.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

archive, xml

More

Packages that depend on excel