This project has moved. For the latest updates, please go here.

Better lambdas

Consider providing a predicate to the Cells/Rows/Columns methods instead of asking for all the object and then applying a .Where to them.

Not so good:
            foreach (var row in worksheet.RowsUsed().Where(r => r.FirstCell().GetString() == "A"))
            {
                // Do something with the row...
            }

Best way:
            using (var rows = worksheet.RowsUsed(r => r.FirstCell().GetString() == "A"))
            {
                foreach (var row in rows)
                {
                    // Do something with the row...
                }
            }




Not so good:
            var column = range.Columns().First(c => c.FirstCell().GetString() == "A");

Best way:
            var column = range.FirstColumnUsed(c => c.FirstCell().GetString() == "A");

Last edited Jan 11, 2012 at 4:25 AM by MDeLeon, version 2