예제 #1
0
        public FormatInfo(CellInfo cell)
        {
            this.cell = cell;
            if (string.IsNullOrEmpty(cell.Format))
                formatIndex = 0;
            else
                formatIndex = cell.Document.Formats.IndexOf(cell.Format);

            FontInfo fontInfo = new FontInfo(cell.Font, cell.ForeColor);
            fontIndex = cell.Document.Fonts.IndexOf(fontInfo);
            if (fontIndex == -1)
            {
                cell.Document.Fonts.Add(fontInfo);
                fontIndex = cell.Document.Fonts.IndexOf(fontInfo);
            }

            if (fontIndex > 3)
                fontIndex++;
        }
예제 #2
0
 private void WriteNumberCell(BinaryWriter writer, CellInfo cell)
 {
     double dValue = Convert.ToDouble(cell.Value);
     ushort[] clData = { BIFF.NumberRecord, 14, (ushort)cell.Row, (ushort)cell.Column, (ushort)cell.FXIndex };
     WriteUshortArray(writer, clData);
     writer.Write(dValue);
 }
예제 #3
0
 private void WriteStringCell(BinaryWriter writer, CellInfo cell)
 {
     string value;
     if (cell.Value is string)
         value = (string)cell.Value;
     else
         value = cell.Value.ToString();
     if (value.Length > 255)
         value = value.Substring(0, 255);
     ushort[] clData = { BIFF.LabelRecord, 0, 0, 0, 0, 0 };
     byte[] plainText = Encoding.GetEncoding(CodePage).GetBytes(value);
     int iLen = plainText.Length;
     clData[1] = (ushort)(8 + iLen);
     clData[2] = (ushort)cell.Row;
     clData[3] = (ushort)cell.Column;
     clData[4] = (ushort)cell.FXIndex;
     clData[5] = (ushort)iLen;
     WriteUshortArray(writer, clData);
     writer.Write(plainText);
 }
예제 #4
0
 private void WriteEmptyCell(BinaryWriter writer, CellInfo cell)
 {
     ushort[] clData = { 0x0201, 6, 0, 0, 15 };
     clData[2] = (ushort)cell.Row;
     clData[3] = (ushort)cell.Column;
     WriteUshortArray(writer, clData);
 }
예제 #5
0
        private void WriteDateCell(BinaryWriter writer, CellInfo cell)
        {
            DateTime value;
            if (cell.Value is DateTime)
            {
                value = (DateTime)cell.Value;
                DateTime baseDate = new DateTime(1899, 12, 31);
                TimeSpan ts = value - baseDate;

                double days = (double)(ts.Days + 1);
                if (days >= 60)
                {
                    days += 1;
                }

                ushort[] clData = { BIFF.NumberRecord, 14, (ushort)cell.Row, (ushort)cell.Column, (ushort)cell.FXIndex };
                WriteUshortArray(writer, clData);
                writer.Write(days);
            }
        }
예제 #6
0
 private void WriteCellValue(BinaryWriter writer, CellInfo cell)
 {
     if (cell.Value == null)
         WriteEmptyCell(writer, cell);
     else
         if (cell.Value is string)
             WriteStringCell(writer, cell);
         else
             if (IsNumber(cell.Value))
                 WriteNumberCell(writer, cell);
             else
                 if (cell.Value is DateTime)
                     WriteDateCell(writer, cell);
                 else
                     WriteStringCell(writer, cell);
 }
예제 #7
0
 internal CellInfo GetCellInfo(int row, int column)
 {
     Int64 key = HashCode(row, column);
     CellInfo result;
     if (cells.TryGetValue(key, out result))
         return result;
     else
     {
         if (rows.IndexOf(row) == -1)
             rows.Add(row);
         result = new CellInfo(this);
         result.Row = row;
         result.Column = column;
         cells.Add(key, result);
         return result;
     }
 }
예제 #8
0
파일: Cell.cs 프로젝트: ozotony/ipocldng
 internal Cell(int row, int column, ExcelDocument document)
 {
     this.document = document;
     cellInfo = document.GetCellInfo(row, column);
 }