Пример #1
0
        private void setCellValue(object value)
        {
            string text = Convert.ToString(value, CultureInfo.InvariantCulture);

            if (String.IsNullOrEmpty(text))
            {
                return;
            }
            if (value is string)
            {
                int index = row.sheet.document.InsertSharedStringItem(text);
                cell.CellValue = new CellValue(index.ToString());
                cell.DataType  = new EnumValue <CellValues>(CellValues.SharedString);
            }
            else if (ExcelCell.IsNumericType(value.GetType()))
            {
                cell.CellValue = new CellValue(text);
                cell.DataType  = new EnumValue <CellValues>(CellValues.Number);
            }
            else
            {
                cell.CellValue = new CellValue(text);
                cell.DataType  = new EnumValue <CellValues>(CellValues.String);
            }
        }
Пример #2
0
 public ExcelCell this[string address]
 {
     get
     {
         return(_rows[ExcelCell.GetRowIndex(address)].Cells[ExcelCell.GetColumnName(address)]);
     }
 }
Пример #3
0
        public ExcelCell GetCell(uint index)
        {
            if (index < 1)
            {
                throw new ArgumentException("Index column cannot be less than 1!");
            }
            if (this.List.ContainsKey(index))
            {
                return(this.List[index]);
            }

            string address = ExcelCell.ConvertToLetter(index) + row.index.ToString();
            Cell   newCell = new Cell()
            {
                CellReference = address
            };
            ExcelCell nextCell = this.List.FirstOrDefault(p => p.Key > index).Value;

            if (nextCell != null)
            {
                row.row.InsertBefore(newCell, nextCell.cell);
            }
            else
            {
                row.row.Append(newCell);
            }
            ExcelCell retVal = new ExcelCell(newCell, row);

            this.List.Add(retVal.Index, retVal);

            return(retVal);
        }
Пример #4
0
 public ExcelCellCollection(ExcelRow row)
 {
     this.row  = row;
     this.List = new SortedDictionary <uint, ExcelCell>();
     foreach (Cell cell in row.row.Elements <Cell>())
     {
         ExcelCell newCell = new ExcelCell(cell, row);
         this.List.Add(newCell.Index, newCell);
     }
 }
Пример #5
0
        public ExcelCell this[string name]
        {
            get
            {
                uint index = ExcelCell.GetColumnIndex(name);
                if (index < 1)
                {
                    throw new ArgumentException("Index column cannot be less than 1!");
                }
                if (this.List.ContainsKey(index))
                {
                    return(this.List[index]);
                }

                return(GetCell(index));
            }
        }
Пример #6
0
        public ExcelCell GetCell(uint index)
        {
            if (index < 1) throw new ArgumentException("Index column cannot be less than 1!");
            if (this.List.ContainsKey(index))
                return this.List[index];

            string address = ExcelCell.ConvertToLetter(index) + row.index.ToString();
            Cell newCell = new Cell() { CellReference = address };
            ExcelCell nextCell = this.List.FirstOrDefault(p => p.Key > index).Value;
            if (nextCell != null)
                row.row.InsertBefore(newCell, nextCell.cell);
            else
                row.row.Append(newCell);
            ExcelCell retVal = new ExcelCell(newCell, row);
            this.List.Add(retVal.Index, retVal);

            return retVal;
        }
Пример #7
0
 public ExcelCellCollection(ExcelRow row)
 {
     this.row = row;
     this.List = new SortedDictionary<uint, ExcelCell>();
     foreach (Cell cell in row.row.Elements<Cell>())
     {
         ExcelCell newCell = new ExcelCell(cell, row);
         this.List.Add(newCell.Index, newCell);
     }
 }
Пример #8
0
 public void Remove(string colName)
 {
     Remove(ExcelCell.GetColumnIndex(colName));
 }
Пример #9
0
 public bool Contains(string colName)
 {
     return(this.List.ContainsKey(ExcelCell.GetColumnIndex(colName)));
 }
Пример #10
0
 public void RemoveCell(string address)
 {
     RemoveCell(ExcelCell.GetRowIndex(address), ExcelCell.GetColumnIndex(ExcelCell.GetColumnName(address)));
 }