public FormatInfo(CellInfo cell) { this.cell = cell; if (string.IsNullOrEmpty(cell.Format)) { this.formatIndex = 0; } else { this.formatIndex = cell.Document.Formats.IndexOf(cell.Format); } FontInfo item = new FontInfo(cell.Font, cell.ForeColor); this.fontIndex = cell.Document.Fonts.IndexOf(item); if (this.fontIndex == -1) { cell.Document.Fonts.Add(item); this.fontIndex = cell.Document.Fonts.IndexOf(item); } if (this.fontIndex > 3) { this.fontIndex++; } }
private void WriteStringCell(BinaryWriter writer, CellInfo cell) { string str; if (cell.Value is string) { str = (string) cell.Value; } else { str = cell.Value.ToString(); } if (str.Length > 0xff) { str = str.Substring(0, 0xff); } ushort[] numArray2 = new ushort[6]; numArray2[0] = 0x204; ushort[] numArray = numArray2; byte[] bytes = Encoding.GetEncoding(this.CodePage).GetBytes(str); int length = bytes.Length; numArray[1] = (ushort) (8 + length); numArray[2] = (ushort) cell.Row; numArray[3] = (ushort) cell.Column; numArray[4] = cell.FXIndex; numArray[5] = (ushort) length; WriteUshortArray(writer, numArray); writer.Write(bytes); }
internal Cell(int row, int column, ExcelDocument document) { this.document = document; this.cellInfo = document.GetCellInfo(row, column); }
private void WriteNumberCell(BinaryWriter writer, CellInfo cell) { double num = Convert.ToDouble(cell.Value); ushort[] numArray = new ushort[] { 0x203, 14, (ushort) cell.Row, (ushort) cell.Column, cell.FXIndex }; WriteUshortArray(writer, numArray); writer.Write(num); }
private void WriteEmptyCell(BinaryWriter writer, CellInfo cell) { ushort[] numArray = new ushort[] { 0x201, 6, 0, 0, 15 }; numArray[2] = (ushort) cell.Row; numArray[3] = (ushort) cell.Column; WriteUshortArray(writer, numArray); }
private void WriteDateCell(BinaryWriter writer, CellInfo cell) { if (cell.Value is DateTime) { DateTime time = (DateTime) cell.Value; DateTime time2 = new DateTime(0x76b, 12, 0x1f); TimeSpan span = (TimeSpan) (time - time2); double num = span.Days + 1; if (num >= 60.0) { num++; } ushort[] numArray = new ushort[] { 0x203, 14, (ushort) cell.Row, (ushort) cell.Column, cell.FXIndex }; WriteUshortArray(writer, numArray); writer.Write(num); } }
private void WriteCellValue(BinaryWriter writer, CellInfo cell) { if (cell.Value == null) { this.WriteEmptyCell(writer, cell); } else if (cell.Value is string) { this.WriteStringCell(writer, cell); } else if (IsNumber(cell.Value)) { this.WriteNumberCell(writer, cell); } else if (cell.Value is DateTime) { this.WriteDateCell(writer, cell); } else { this.WriteStringCell(writer, cell); } }
internal CellInfo GetCellInfo(int row, int column) { CellInfo info; long key = HashCode(row, column); if (!this.cells.TryGetValue(key, out info)) { if (this.rows.IndexOf(row) == -1) { this.rows.Add(row); } info = new CellInfo(this) { Row = row, Column = column }; this.cells.Add(key, info); } return info; }