Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

New Post: Reading Specific Columns or other ideas?

$
0
0
If you only need the Cells from specific Columns you can try to do this:
private static List<ICell> GetSpecificColumnsCells(ISheet sheet, int fromColumn, int toColumn)
        {
            List<ICell> specificValues = new List<ICell>();

            //In here we are filtering ONLY the columns that we want
            var records = ((HSSFSheet)sheet).Sheet.GetValueRecords()
                                    .Where((v) => v.Column >= fromColumn && v.Column <= toColumn)
                                    .Select((s) => s);

            foreach (var record in records)
            {   //GetRow will never throw exception cause we are pulling the records from existing ones
                specificValues.Add(sheet.GetRow(record.Row).GetCell(record.Column));
            }

            return specificValues;
        }

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>