Flutter4 min read

Working with CSV, Excel, and ODS in Flutter Without Multiple Packages

Real-world CSV, Excel, and ODS files often break Dart parsers in subtle ways. This article explains why table_parser was created to reliably parse, modify, and export spreadsheet data using one consistent API.

From MVC to MVVM in Flutter

While working on excel_translator, I kept facing the same problem: parsing CSV, Excel, and ODS files reliably in Dart without stacking multiple packages for each format.

At first, this did not look like a big issue. These files are just rows and columns of data. But after dealing with real files coming from real users and different systems, the problem became very clear.

This post is about that experience, and why it led to creating table_parser.


When Table Files Come From the Real World

Modern MVC to MVVM Interface Panels

Most CSV examples online look very clean:

Name,Age,City
John,30,New York

But files uploaded by users often look like this:

"Smith, John","Senior Developer",85000
"Doe, Jane","Marketing Manager",75000
"Johnson, Mike","HR Director ""People Ops""",90000

This is valid CSV.

But now you must handle:

  • commas inside text
  • quoted fields
  • escaped quotes
  • custom separators like ;
  • different line endings depending on the system

Many parsers don’t throw an error here.

They return wrong columns silently, which is much worse.


The First Approach: Use Existing Packages

Initially, I used spreadsheet_decoder.

It is a good package and works well for reading XLSX and ODS files.

But when dealing with complex CSV and real table manipulation needs, some friction appeared:

  • CSV parsing was not flexible enough
  • Quoted fields failed in edge cases
  • Updating table data and exporting it back was not convenient
  • The package felt more like a decoder than a table tool

And in real applications, we rarely just read tables.

We usually need to work with them.


Another Hidden Issue: Too Many Packages

Because excel_translator supports CSV, XLSX, and ODS, I had to depend on different packages to parse each format.

One for CSV.
One for Excel.
One for ODS.

This created unnecessary complexity:

  • Multiple dependencies for the same concept: table data
  • Different APIs for each format
  • Inconsistent behavior
  • Harder maintenance over time

From the app’s point of view, these files are not different.

They are all just rows and columns.

So the question became:

Why do we treat CSV, Excel, and ODS as completely separate problems?


The Real Need Was Not “Decode”

What was actually needed was:

  • Parse messy CSV reliably
  • Read Excel and ODS with the same API
  • Update cells
  • Insert rows and columns
  • Export the file back
  • Use one package instead of three

In other words, treat spreadsheet files as modifiable tables, not just decoded content.

That is where table_parser comes in.


What Makes table_parser Different

CSV is treated as a first-class format

You have full control over how CSV is parsed:

var decoder = TableParser.decodeCsv(
  csvContent,
  separator: ';',
  textDelimiter: '"',
  shouldParseNumbers: true,
  eol: '\n',
  update: true,
);

This is important because CSV files in the real world are rarely standard.


You can modify the table easily

decoder.updateCell('Sheet1', 1, 1, 42);
decoder.insertRow('Sheet1', 2);
decoder.insertColumn('Sheet1', 0);

var newBytes = decoder.encode();

This is very useful for:

  • admin panels
  • data import tools
  • report processors
  • backend Dart services

Same API for CSV, XLSX, and ODS

var bytes = File('report.xlsx').readAsBytesSync();
var decoder = TableParser.decodeBytes(bytes, update: true);

No format-specific logic is needed.


A Small Example

var csv = '''Name,Age,City
"Smith, John",30,"New York"''';

var decoder = TableParser.decodeCsv(csv, textDelimiter: '"');
var table = decoder.tables['Sheet1']!;

for (var row in table.rows) {
  print(row);
}

The quoted name is handled correctly without breaking the columns.


Where This Becomes Very Useful

This approach is especially helpful when your app needs to:

  • Import user data from spreadsheets
  • Process reports exported from other systems
  • Let users upload, edit, and download files again
  • Build internal tools that depend on tabular data

In these cases, reliability matters more than simplicity.


Easy Migration from spreadsheet_decoder

If you already use spreadsheet_decoder, switching is simple:

dependencies:
  table_parser: ^1.0.1
import 'package:table_parser/table_parser.dart';

Most of the API remains familiar.


Closing

Handling spreadsheet files in Dart is not only about decoding bytes into rows.

When you need to read, modify, and export table data across CSV, Excel, and ODS with one consistent API, table_parser becomes a much more practical solution.

This package was created from repeated problems in real projects, and it aims to make table handling in Flutter and Dart more reliable and easier to maintain.