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; } } }
public int GetRowNum(SXSSFRow row) { foreach (KeyValuePair <int, SXSSFRow> entry in _rows) { if (entry.Value == row) { return(entry.Key); } } return(-1); }
/** * 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(); } }
/** * 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(); } }
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); }
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; } }
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; }
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; } }
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); }
/** * 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++; } }
/** * 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(); }
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)); }
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)); }
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; }
public SXSSFCell(SXSSFRow row, CellType cellType) { _row = row; SetType(cellType); }
public void ChangeRowNum(SXSSFRow row, int newRowNum) { RemoveRow(row); _rows.Add(newRowNum, row); UpdateIndexWhenAdd(newRowNum); }
public void ChangeRowNum(SXSSFRow row, int newRowNum) { RemoveRow(row); _rows.Add(newRowNum, row); }