示例#1
0
        private void collapseRow(int rowIndex)
        {
            SXSSFRow row = (SXSSFRow)GetRow(rowIndex);

            if (row == null)
            {
                throw new InvalidOperationException("Invalid row number(" + rowIndex + "). Row does not exist.");
            }
            else
            {
                int startRow = FindStartOfRowOutlineGroup(rowIndex);

                // Hide all the columns until the end of the group
                int      lastRow    = WriteHidden(row, startRow, true);
                SXSSFRow lastRowObj = (SXSSFRow)GetRow(lastRow);
                if (lastRowObj != null)
                {
                    lastRowObj.Collapsed = true;
                }
                else
                {
                    SXSSFRow newRow = (SXSSFRow)CreateRow(lastRow);
                    newRow.Collapsed = true;
                }
            }
        }
示例#2
0
 public int GetRowNum(SXSSFRow row)
 {
     foreach (KeyValuePair <int, SXSSFRow> entry in _rows)
     {
         if (entry.Value == row)
         {
             return(entry.Key);
         }
     }
     return(-1);
 }
示例#3
0
        /**
         * Set row groupings (like groupRow) in a stream-friendly manner
         *
         * <p>
         *    groupRows requires all rows in the group to be in the current window.
         *    This is not always practical.  Instead use setRowOutlineLevel to
         *    explicitly set the group level.  Level 1 is the top level group,
         *    followed by 2, etc.  It is up to the user to ensure that level 2
         *    groups are correctly nested under level 1, etc.
         * </p>
         *
         * @param rownum    index of row to update (0-based)
         * @param level     outline level (greater than 0)
         */
        public void SetRowOutlineLevel(int rownum, int level)
        {
            SXSSFRow row = _rows[rownum];

            row.OutlineLevel = level;
            if (level > 0 && level > outlineLevelRow)
            {
                outlineLevelRow = level;
                SetWorksheetOutlineLevelRow();
            }
        }
示例#4
0
 /**
  * Write a row to the file
  *
  * @param rownum 0-based row number
  * @param row    a row
  */
 public void WriteRow(int rownum, SXSSFRow row)
 {
     BeginRow(rownum, row);
     using (var cells = row.GetEnumerator())
     {
         int columnIndex = 0;
         while (cells.MoveNext())
         {
             WriteCell(columnIndex++, cells.Current);
         }
         EndRow();
     }
 }
示例#5
0
        private int WriteHidden(SXSSFRow xRow, int rowIndex, bool hidden)
        {
            int level   = xRow.OutlineLevel;
            var currRow = (SXSSFRow)GetRow(rowIndex);

            while (currRow != null && currRow.OutlineLevel >= level)
            {
                currRow.Hidden = hidden;
                rowIndex++;
                currRow = (SXSSFRow)GetRow(rowIndex);
            }
            return(rowIndex);
        }
示例#6
0
        private void flushOneRow()
        {
            int firstRowNum = _rows.FirstOrDefault().Key;

            if (firstRowNum != null)
            {
                int      rowIndex = firstRowNum;
                SXSSFRow row      = _rows[firstRowNum];
                // Update the best fit column widths for auto-sizing just before the rows are flushed
                // _autoSizeColumnTracker.UpdateColumnWidths(row);
                _writer.WriteRow(rowIndex, row);
                _rows.Remove(firstRowNum);
                lastFlushedRowNumber = rowIndex;
            }
        }
示例#7
0
        private void BeginRow(int rownum, SXSSFRow row)
        {
            WriteAsBytes("<row r=\"");
            WriteAsBytes(rownum + 1);
            WriteAsBytes("\"");

            if (row.HasCustomHeight())
            {
                WriteAsBytes(" customHeight=\"true\"  ht=\"");
                WriteAsBytes(row.HeightInPoints);
                WriteAsBytes("\"");
            }
            if (row.ZeroHeight)
            {
                WriteAsBytes(" hidden=\"true\"");
            }
            if (row.IsFormatted)
            {
                WriteAsBytes(" s=\"");
                WriteAsBytes(row.RowStyle.Index);
                WriteAsBytes("\"");
                WriteAsBytes(" customFormat=\"1\"");
            }

            if (row.OutlineLevel != 0)
            {
                WriteAsBytes(" outlineLevel=\"");
                WriteAsBytes(row.OutlineLevel);
                WriteAsBytes("\"");
            }
            if (row.Hidden != null)
            {
                WriteAsBytes(" hidden=\"");
                WriteAsBytes(row.Hidden.Value ? "1" : "0");
                WriteAsBytes("\"");
            }
            if (row.Collapsed != null)
            {
                WriteAsBytes(" collapsed=\"");
                WriteAsBytes(row.Collapsed.Value ? "1" : "0");
                WriteAsBytes("\"");
            }

            WriteAsBytes(">\n");

            RowNum = rownum;
        }
示例#8
0
        private void FlushOneRow()
        {
            KeyValuePair <int, SXSSFRow> firstRow = _rows.FirstOrDefault();

            //KeyValuePair is struct, so check value instead of key
            if (firstRow.Value != null)
            {
                int      firstRowNum = firstRow.Key;
                int      rowIndex    = firstRowNum;
                SXSSFRow row         = _rows[firstRowNum];
                // Update the best fit column widths for auto-sizing just before the rows are flushed
                //_autoSizeColumnTracker.UpdateColumnWidths(row);
                _writer.WriteRow(rowIndex, row);
                _rows.Remove(firstRowNum);
                lastFlushedRowNumber = rowIndex;
            }
        }
示例#9
0
        public IRow CreateRow(int rownum)
        {
            int maxrow = SpreadsheetVersion.EXCEL2007.LastRowIndex;

            if (rownum < 0 || rownum > maxrow)
            {
                throw new ArgumentException("Invalid row number (" + rownum
                                            + ") outside allowable range (0.." + maxrow + ")");
            }

            // attempt to overwrite a row that is already flushed to disk
            if (rownum <= _writer.NumberLastFlushedRow)
            {
                throw new ArgumentException(
                          "Attempting to write a row[" + rownum + "] " +
                          "in the range [0," + _writer.NumberLastFlushedRow + "] that is already written to disk.");
            }

            // attempt to overwrite a existing row in the input template
            if (_sh.PhysicalNumberOfRows > 0 && rownum <= _sh.LastRowNum)
            {
                throw new ArgumentException(
                          "Attempting to write a row[" + rownum + "] " +
                          "in the range [0," + _sh.LastRowNum + "] that is already written to disk.");
            }

            SXSSFRow newRow = new SXSSFRow(this);

            _rows[rownum] = newRow;

            UpdateIndexWhenAdd(rownum);

            allFlushed = false;
            if (_randomAccessWindowSize >= 0 && _rows.Count > _randomAccessWindowSize)
            {
                try
                {
                    FlushRows(_randomAccessWindowSize, false);
                }
                catch (IOException ioe)
                {
                    throw new RuntimeException(ioe);
                }
            }
            return(newRow);
        }
示例#10
0
        /**
         * Write a row to the file
         *
         * @param rownum 0-based row number
         * @param row    a row
         */
        public void WriteRow(int rownum, SXSSFRow row)
        {
            BeginRow(rownum, row);
            using (var cells = row.GetEnumerator())
            {
                int columnIndex = 0;
                while (cells.MoveNext())
                {
                    WriteCell(columnIndex++, cells.Current);
                }
                EndRow();
            }

            if (LowestIndexOfFlushedRows == -1 || LowestIndexOfFlushedRows > rownum)
            {
                LowestIndexOfFlushedRows = rownum;
                NumberOfFlushedRows++;
            }
        }
示例#11
0
        /**
         * Write a row to the file
         *
         * @param rownum 0-based row number
         * @param row    a row
         */
        public void WriteRow(int rownum, SXSSFRow row)
        {
            if (NumberOfFlushedRows == 0)
            {
                LowestIndexOfFlushedRows = rownum;
            }

            NumberLastFlushedRow          = Math.Max(rownum, NumberLastFlushedRow);
            NumberOfCellsOfLastFlushedRow = row.LastCellNum;
            NumberOfFlushedRows++;
            BeginRow(rownum, row);
            var cells       = row.AllCellsIterator();
            int columnIndex = 0;

            while (cells.HasNext())
            {
                WriteCell(columnIndex++, cells.Next());
            }
            EndRow();
        }
示例#12
0
        public SXSSFEvaluationCell getCell(int rowIndex, int columnIndex)
        {
            SXSSFRow row = _xs._rows[rowIndex];

            if (row == null)
            {
                if (rowIndex <= _xs.lastFlushedRowNumber)
                {
                    throw new RowFlushedException(rowIndex);
                }
                return(null);
            }
            SXSSFCell cell = (SXSSFCell)row.Cells[columnIndex];

            if (cell == null)
            {
                return(null);
            }
            return(new SXSSFEvaluationCell(cell, this));
        }
示例#13
0
        public IEvaluationCell GetCell(int rowIndex, int columnIndex)
        {
            SXSSFRow row = (SXSSFRow)_xs.GetRow(rowIndex);

            if (row == null)
            {
                if (rowIndex <= _xs.LastFlushedRowNumber)
                {
                    throw new RowFlushedException(rowIndex);
                }
                return(null);
            }
            SXSSFCell cell = (SXSSFCell)row.GetCell(columnIndex);

            if (cell == null)
            {
                return(null);
            }
            return(new SXSSFEvaluationCell(cell, this));
        }
示例#14
0
        private void BeginRow(int rownum, IRow row1)
        {
            SXSSFRow row = row1 as SXSSFRow;

            WriteAsBytes(OutputStream, "<row r=\"" + (rownum + 1) + "\"");

            if (row.HasCustomHeight())
            {
                WriteAsBytes(OutputStream, " customHeight=\"true\"  ht=\"" + row.HeightInPoints + "\"");
            }
            if (row.ZeroHeight)
            {
                WriteAsBytes(OutputStream, " hidden=\"true\"");
            }
            if (row.IsFormatted)
            {
                WriteAsBytes(OutputStream, " s=\"" + row.RowStyleIndex + "\"");

                WriteAsBytes(OutputStream, " customFormat=\"1\"");
            }

            if (row.OutlineLevel != 0)
            {
                WriteAsBytes(OutputStream, " outlineLevel=\"" + row.OutlineLevel + "\"");
            }
            if (row.Hidden != null)
            {
                WriteAsBytes(OutputStream, " hidden=\"" + (row.Hidden.Value ? "1" : "0") + "\"");
            }
            if (row.Collapsed != null)
            {
                WriteAsBytes(OutputStream, " collapsed=\"" + (row.Collapsed.Value ? "1" : "0") + "\"");
            }

            WriteAsBytes(OutputStream, ">\n");

            this.RowNum = rownum;
        }
示例#15
0
 public SXSSFCell(SXSSFRow row, CellType cellType)
 {
     _row = row;
     SetType(cellType);
 }
示例#16
0
 public void ChangeRowNum(SXSSFRow row, int newRowNum)
 {
     RemoveRow(row);
     _rows.Add(newRowNum, row);
     UpdateIndexWhenAdd(newRowNum);
 }
示例#17
0
 public void ChangeRowNum(SXSSFRow row, int newRowNum)
 {
     RemoveRow(row);
     _rows.Add(newRowNum, row);
 }