/// <summary> /// Removes a row record /// This method is not loc sensitive, it Resets loc to = dimsloc so no worries. /// </summary> /// <param name="row">the row record to Remove</param> public void RemoveRow(RowRecord row) { _rowsAggregate.RemoveRow(row); }
/// <summary> /// Creates an HSSFRow from a low level RowRecord object. Only HSSFSheet should do /// this. HSSFSheet uses this when an existing file is Read in. /// </summary> /// <param name="book">low-level Workbook object containing the sheet that Contains this row</param> /// <param name="sheet"> low-level Sheet object that Contains this Row</param> /// <param name="record">the low level api object this row should represent</param> ///<see cref="LF.Utils.NPOI.HSSF.UserModel.HSSFSheet.CreateRow(int)"/> public HSSFRow(HSSFWorkbook book, HSSFSheet sheet, RowRecord record) { this.book = book; this.sheet = sheet; row = record; RowNum=(record.RowNumber); // Don't trust colIx boundaries as read by other apps // set the RowRecord empty for the moment record.SetEmpty(); }
public override Object Clone() { RowRecord rec = new RowRecord(field_1_row_number); rec.field_2_first_col = field_2_first_col; rec.field_3_last_col = field_3_last_col; rec.field_4_height = field_4_height; rec.field_5_optimize = field_5_optimize; rec.field_6_reserved = field_6_reserved; rec.field_7_option_flags = field_7_option_flags; rec.field_8_xf_index = field_8_xf_index; return rec; }
/// <summary> /// Adds a row record to the sheet /// This method is "loc" sensitive. Meaning you need to Set LOC to where you /// want it to start searching. If you don't know do this: SetLoc(GetDimsLoc). /// When Adding several rows you can just start at the last one by leaving loc /// at what this Sets it to. /// </summary> /// <param name="row">the row record to be Added</param> public void AddRow(RowRecord row) { //if (log.Check(POILogger.DEBUG)) // log.Log(POILogger.DEBUG, "AddRow "); DimensionsRecord d = _dimensions; if (row.RowNumber >= d.LastRow) { d.LastRow = (row.RowNumber + 1); } if (row.RowNumber < d.FirstRow) { d.FirstRow = (row.RowNumber); } //IndexRecord index = null; //If the row exists Remove it, so that any cells attached to the row are Removed RowRecord existingRow = _rowsAggregate.GetRow(row.RowNumber); if (existingRow != null) { _rowsAggregate.RemoveRow(existingRow); } _rowsAggregate.InsertRow(row); //if (log.Check(POILogger.DEBUG)) // log.Log(POILogger.DEBUG, "exit AddRow"); }
/// <summary> /// Used internally to Create a high level Row object from a low level row object. /// USed when Reading an existing file /// </summary> /// <param name="row">low level record to represent as a high level Row and Add to _sheet.</param> /// <returns>HSSFRow high level representation</returns> private HSSFRow CreateRowFromRecord(RowRecord row) { HSSFRow hrow = new HSSFRow(_workbook, this, row); AddRow(hrow, false); return hrow; }
/// <summary> /// used internally to Set the properties given a Sheet object /// </summary> /// <param name="sheet">The _sheet.</param> private void SetPropertiesFromSheet(InternalSheet sheet) { RowRecord row = _sheet.NextRow; bool rowRecordsAlreadyPresent = row != null; while (row != null) { CreateRowFromRecord(row); row = sheet.NextRow; } CellValueRecordInterface[] cvals = sheet.GetValueRecords(); long timestart = DateTime.Now.Millisecond; //if (log.Check(POILogger.DEBUG)) // log.Log(DEBUG, "Time at start of cell creating in HSSF _sheet = ", // timestart); HSSFRow lastrow = null; // Add every cell to its row for (int i = 0; i < cvals.Length; i++) { CellValueRecordInterface cval = cvals[i]; long cellstart = DateTime.Now.Millisecond; HSSFRow hrow = lastrow; if ((lastrow == null) || (lastrow.RowNum != cval.Row)) { hrow = (HSSFRow)GetRow(cval.Row); if (hrow == null) { // Some tools (like Perl module SpReadsheet::WriteExcel - bug 41187) skip the RowRecords // Excel, OpenOffice.org and GoogleDocs are all OK with this, so POI should be too. if (rowRecordsAlreadyPresent) { // if at least one row record is present, all should be present. throw new Exception("Unexpected missing row when some rows already present"); } // Create the row record on the fly now. RowRecord rowRec = new RowRecord(cval.Row); _sheet.AddRow(rowRec); hrow = CreateRowFromRecord(rowRec); } } if (hrow != null) { lastrow = hrow; if (cval is Record) { //if (log.Check(POILogger.DEBUG)) // log.Log(DEBUG, "record id = " + StringUtil.ToHexString(((Record)cval).Sid)); } hrow.CreateCellFromRecord(cval); //if (log.Check(POILogger.DEBUG)) // log.Log(DEBUG, "record took ",DateTime.Now.Millisecond - cellstart); } else { cval = null; } } //if (log.Check(POILogger.DEBUG)) // log.Log(DEBUG, "total _sheet cell creation took ", // DateTime.Now.Millisecond - timestart); }
public int WriteHidden(RowRecord rowRecord, int row, bool hidden) { int level = rowRecord.OutlineLevel; while (rowRecord != null && this.GetRow(row).OutlineLevel >= level) { rowRecord.ZeroHeight = (hidden); row++; rowRecord = this.GetRow(row); } return row - 1; }
public void RemoveRow(RowRecord row) { int rowIndex = row.RowNumber; _valuesAgg.RemoveAllCellsValuesForRow(rowIndex); int key = rowIndex; RowRecord rr = (RowRecord)_rowRecords[key]; _rowRecords.Remove(key); if (rr == null) { throw new Exception("Invalid row index (" + key + ")"); } if (row != rr) { _rowRecords[key] = rr; throw new Exception("Attempt to remove row that does not belong to this sheet"); } // Clear the cached values _rowRecordValues = null; }
public void InsertRow(RowRecord row) { _rowRecords[row.RowNumber] = row; // Clear the cached values _rowRecordValues = null; if (row.RowNumber < firstrow|| firstrow == -1) { firstrow = row.RowNumber; } if (row.RowNumber > lastrow|| lastrow == -1) { lastrow = row.RowNumber; } }