/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="wb">The workbook.</param>
		/// <exception cref="ArgumentNullException">Exception is thrown if wb is null.</exception>
		public ExcelObject(Workbook wb)
		{
			if(wb == null)
				throw new ArgumentNullException("wb");

			_wb = wb;
		}
Beispiel #2
0
		internal Style(Workbook wb, XfRecord xf) : base(wb)
		{	
			if(xf.FontIdx > 0 && xf.FontIdx < wb.Fonts.Count)
    	        _font = wb.Fonts[xf.FontIdx - 1];
		    _format = wb.Formats[xf.FormatIdx];
			_typeAndProtection = xf.TypeAndProtection;
			if(_typeAndProtection.IsCell)
				_parentStyle = wb.Styles[xf.ParentIdx];
			_horizontalAlignment = xf.HorizontalAlignment;
			_wrapped = xf.Wrapped;
			_verticalAlignment = xf.VerticalAlignment;
			_rotation = xf.Rotation;
			_indentLevel = xf.IndentLevel;
			_shrinkContent = xf.ShrinkContent;
			_parentStyleAttributes = xf.ParentStyle;
			_leftLineStyle = xf.LeftLineStyle;
			_rightLineStyle = xf.RightLineStyle;
			_topLineStyle = xf.TopLineStyle;
			_bottomLineStyle = xf.BottomLineStyle;
			_leftLineColor = wb.Palette.GetColor(xf.LeftLineColor);
			_rightLineColor = wb.Palette.GetColor(xf.RightLineColor);
			_diagonalRightTopToLeftBottom = xf.DiagonalRightTopToLeftBottom;
			_diagonalLeftBottomToTopRight = xf.DiagonalLeftBottomToTopRight;
			_topLineColor = wb.Palette.GetColor(xf.TopLineColor);
			_bottomLineColor = wb.Palette.GetColor(xf.BottomLineColor);
			_diagonalLineColor = wb.Palette.GetColor(xf.DiagonalLineColor);
			_diagonalLineStyle = xf.DiagonalLineStyle;
			_fillPattern = xf.FillPattern;
			_patternColor = wb.Palette.GetColor(xf.PatternColor);
			_patternBackground = wb.Palette.GetColor(xf.PatternBackground);
		}
Beispiel #3
0
		internal Palette(Workbook wb) : base(wb)
		{
			_builtIn = new PaletteEntry[] { new PaletteEntry(wb, Color.Black), new PaletteEntry(wb, Color.White), 
				new PaletteEntry(wb, Color.Red), new PaletteEntry(wb, Color.Green), 
				new PaletteEntry(wb, Color.Blue), new PaletteEntry(wb, Color.Yellow), 
				new PaletteEntry(wb, Color.Magenta), new PaletteEntry(wb, Color.Cyan)
										  };

			_others = new Dictionary<int, PaletteEntry>(3);
			_others[0x0040] = new PaletteEntry(wb, Color.FromKnownColor(KnownColor.ActiveBorder));
			_others[0x0041] = new PaletteEntry(wb, Color.FromKnownColor(KnownColor.Window));
			_others[0x7FFF] = new PaletteEntry(wb, Color.FromKnownColor(KnownColor.WindowText));

			_colors = new PaletteEntry[56];
			int idx = 0;
			foreach(int c in _defaultPalette)
				_colors[idx++] = new PaletteEntry(wb, Color.FromArgb(c));
		}
Beispiel #4
0
		internal Format(Workbook wb, string formatValue) : base(wb)
		{
			_formatValue = formatValue;
		}
Beispiel #5
0
		internal Format(Workbook wb, Net.SourceForge.Koogra.Excel.Records.FormatRecord f) : base(wb)
		{
			_formatValue = f.Format;
		}
		internal PaletteEntry(Workbook wb, Color color) : base(wb)
		{
			_color = color;
		}
Beispiel #7
0
 internal Cell(Workbook wb, object value)
     : base(wb)
 {
     _value = value;
 }
Beispiel #8
0
        internal Worksheet(Workbook wb, BoundSheetRecord sheet, SortedList<long, Biff> records)
            : base(wb)
        {
            _name = sheet.Name;

            int idx = records.IndexOfKey((long)sheet.BofPos);

            _hyperlinks = new HyperLinkCollection(wb);

            for (int i = idx + 1; i < records.Count; ++i)
            {
                Biff biff = records.Values[i];
                if (biff is HyperLinkRecord)
                    _hyperlinks.Add((HyperLinkRecord)biff);
                else if (biff is EofRecord)
                    break;
            }

            BofRecord bof = (BofRecord)records.Values[idx++];

            Biff seeker = records.Values[idx++];

            while (!(seeker is IndexRecord))
                seeker = records.Values[idx++];

            IndexRecord index = (IndexRecord)seeker;

            _rows = new RowCollection(wb);
            foreach (uint indexPos in index.Rows)
            {
                long dbCellPos = indexPos;
                int dbCellIdx = records.IndexOfKey(dbCellPos);
                DbCellRecord dbCell = (DbCellRecord)records[dbCellPos];

                if (dbCell.RowOffset > 0)
                {
                    long rowPos = dbCellPos - dbCell.RowOffset;
                    int recIndex = records.IndexOfKey(rowPos);
                    Debug.Assert(recIndex != -1);

                    Biff record = records.Values[recIndex++];
                    while (record is RowRecord)
                    {
                        RowRecord row = (RowRecord)record;
                        Row currentRow = new Row(Workbook, row);
                        _rows.Add(row.RowNumber, currentRow);

                        record = records.Values[recIndex++];
                    }

                    while (recIndex <= dbCellIdx)
                    {
                        if (!(record is CellRecord))
                        {
                            record = records.Values[recIndex++];
                            continue;
                        }

                        CellRecord thecell = (CellRecord)record;
                        Row currentRow = _rows[thecell.Row];

                        if (thecell is SingleColCellRecord)
                        {
                            SingleColCellRecord cell = (SingleColCellRecord)thecell;
                            object val = cell.Value;

                            Cell newCell = new Cell(Workbook, val);
                            if (cell is RowColXfCellRecord)
                            {
                                RowColXfCellRecord xfCell = (RowColXfCellRecord)cell;

                                Style style = Workbook.Styles[xfCell.Xf];
                                Debug.Assert(style != null);
                                newCell.Style = style;
                            }
                            currentRow.Cells.Add((byte)cell.Col, newCell);
                        }
                        else
                        {
                            MultipleColCellRecord cells = (MultipleColCellRecord)thecell;
                            for (ushort i = cells.FirstCol; i <= cells.LastCol; ++i)
                            {
                                object val = cells.GetValue(i);
                                if (val != null)
                                {
                                    Cell newCell = null;
                                    if (val is RkRec)
                                    {
                                        RkRec rk = (RkRec)val;

                                        newCell = new Cell(Workbook, rk.Value);
                                        Style style = Workbook.Styles[rk.Xf];
                                        Debug.Assert(style != null);
                                        newCell.Style = style;
                                    }
                                    else
                                        newCell = new Cell(Workbook, val);

                                    currentRow.Cells.Add((byte)i, newCell);
                                }
                            }
                        }

                        record = records.Values[recIndex++];
                    }
                }
            }
        }
Beispiel #9
0
 public ExcelUtils(System.IO.Stream stream)
 {
     this.book = new Workbook(stream);
 }
Beispiel #10
0
 public ExcelUtils(string path)
 {
     this.book = new Workbook(path);
 }
Beispiel #11
0
 internal Row(Workbook wb, RowRecord row)
     : base(wb)
 {
     _cells = new CellCollection(wb);
 }
Beispiel #12
0
        internal Worksheet(Workbook wb, BoundSheetRecord sheet, SortedList <long, Biff> records)
            : base(wb)
        {
            _name = sheet.Name;

            int idx = records.IndexOfKey((long)sheet.BofPos);

            _hyperlinks = new HyperLinkCollection(wb);

            for (int i = idx + 1; i < records.Count; ++i)
            {
                Biff biff = records.Values[i];
                if (biff is HyperLinkRecord)
                {
                    _hyperlinks.Add((HyperLinkRecord)biff);
                }
                else if (biff is EofRecord)
                {
                    break;
                }
            }

            BofRecord bof = (BofRecord)records.Values[idx++];

            Biff seeker = records.Values[idx++];

            while (!(seeker is IndexRecord))
            {
                seeker = records.Values[idx++];
            }

            IndexRecord index = (IndexRecord)seeker;

            _rows = new RowCollection(wb);
            foreach (uint indexPos in index.Rows)
            {
                long         dbCellPos = indexPos;
                int          dbCellIdx = records.IndexOfKey(dbCellPos);
                DbCellRecord dbCell    = (DbCellRecord)records[dbCellPos];

                if (dbCell.RowOffset > 0)
                {
                    long rowPos   = dbCellPos - dbCell.RowOffset;
                    int  recIndex = records.IndexOfKey(rowPos);
                    Debug.Assert(recIndex != -1);

                    Biff record = records.Values[recIndex++];
                    while (record is RowRecord)
                    {
                        RowRecord row        = (RowRecord)record;
                        Row       currentRow = new Row(Workbook, row);
                        _rows.Add(row.RowNumber, currentRow);

                        record = records.Values[recIndex++];
                    }

                    while (recIndex <= dbCellIdx)
                    {
                        if (!(record is CellRecord))
                        {
                            record = records.Values[recIndex++];
                            continue;
                        }

                        CellRecord thecell    = (CellRecord)record;
                        Row        currentRow = _rows[thecell.Row];

                        if (thecell is SingleColCellRecord)
                        {
                            SingleColCellRecord cell = (SingleColCellRecord)thecell;
                            object val = cell.Value;

                            Cell newCell = new Cell(Workbook, val);
                            if (cell is RowColXfCellRecord)
                            {
                                RowColXfCellRecord xfCell = (RowColXfCellRecord)cell;

                                Style style = Workbook.Styles[xfCell.Xf];
                                Debug.Assert(style != null);
                                newCell.Style = style;
                            }
                            currentRow.Cells.Add((byte)cell.Col, newCell);
                        }
                        else
                        {
                            MultipleColCellRecord cells = (MultipleColCellRecord)thecell;
                            for (ushort i = cells.FirstCol; i <= cells.LastCol; ++i)
                            {
                                object val = cells.GetValue(i);
                                if (val != null)
                                {
                                    Cell newCell = null;
                                    if (val is RkRec)
                                    {
                                        RkRec rk = (RkRec)val;

                                        newCell = new Cell(Workbook, rk.Value);
                                        Style style = Workbook.Styles[rk.Xf];
                                        Debug.Assert(style != null);
                                        newCell.Style = style;
                                    }
                                    else
                                    {
                                        newCell = new Cell(Workbook, val);
                                    }

                                    currentRow.Cells.Add((byte)i, newCell);
                                }
                            }
                        }

                        record = records.Values[recIndex++];
                    }
                }
            }
        }
Beispiel #13
0
 internal Format(Workbook wb, string formatValue) : base(wb)
 {
     _formatValue = formatValue;
 }
Beispiel #14
0
 internal Format(Workbook wb, Net.SourceForge.Koogra.Excel.Records.FormatRecord f) : base(wb)
 {
     _formatValue = f.Format;
 }