Example #1
0
 public TableCell this[string columnName]
 {
     get
     {
         TableColumn tc = Parent
                          .TableColumns()
                          .Where(x => x.Name.ToLower() == columnName.ToLower())
                          .FirstOrDefault();
         if (tc == null)
         {
             throw new Exception("Invalid column name: " + columnName);
         }
         string[] refs          = Parent.Ref.Split(':');
         string[] startRefs     = LocalExtensions.SplitAddress(refs[0]);
         string   columnAddress = (startRefs[0].ColumnAddressToIndex() + tc.ColumnIndex).IndexToColumnAddress();
         Cell     cell          = Row.Cells().Where(c => c.ColumnId == columnAddress).FirstOrDefault();
         if (cell != null)
         {
             if (cell.Type == "s")
             {
                 return(new TableCell(cell.SharedString));
             }
             else
             {
                 return(new TableCell(cell.Value));
             }
         }
         else
         {
             return(new TableCell(""));
         }
     }
 }
Example #2
0
        public IEnumerable <TableRow> TableRows()
        {
            string refStart        = Ref.Split(':').First();
            int    rowStart        = Int32.Parse(LocalExtensions.SplitAddress(refStart)[1]);
            string refEnd          = Ref.Split(':').ElementAt(1);
            int    rowEnd          = Int32.Parse(LocalExtensions.SplitAddress(refEnd)[1]);
            int    headerRowsCount = HeaderRowCount == null ? 0 : (int)HeaderRowCount;
            int    totalRowsCount  = TotalsRowCount == null ? 0 : (int)TotalsRowCount;

            return(Parent
                   .Rows()
                   .Skip(headerRowsCount)
                   .SkipLast(totalRowsCount)
                   .Where(r =>
            {
                int rowId = Int32.Parse(r.RowId);
                return rowId >= rowStart && rowId <= rowEnd;
            }
                          )
                   .Select(r => new TableRow(this)
            {
                Row = r
            }));
        }