public void TestLastAndFirstColumns_bug46654() { int ROW_IX = 10; int COL_IX = 3; HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Sheet1"); RowRecord rowRec = new RowRecord(ROW_IX); rowRec.FirstCol = ((short)2); rowRec.LastCol = ((short)5); BlankRecord br = new BlankRecord(); br.Row = (ROW_IX); br.Column = ((short)COL_IX); sheet.Sheet.AddValueRecord(ROW_IX, br); HSSFRow row = new HSSFRow(workbook, sheet, rowRec); ICell cell = row.CreateCellFromRecord(br); if (row.FirstCellNum == 2 && row.LastCellNum == 5) { throw new AssertionException("Identified bug 46654a"); } Assert.AreEqual(COL_IX, row.FirstCellNum); Assert.AreEqual(COL_IX + 1, row.LastCellNum); row.RemoveCell(cell); Assert.AreEqual(-1, row.FirstCellNum); Assert.AreEqual(-1, row.LastCellNum); }
public void TestRowValueAggregatesOrder_bug45145() { InternalSheet sheet = InternalSheet.CreateSheet(); RowRecord rr = new RowRecord(5); sheet.AddRow(rr); CellValueRecordInterface cvr = new BlankRecord(); cvr.Column = 0; cvr.Row = (5); sheet.AddValueRecord(5, cvr); int dbCellRecordPos = GetDbCellRecordPos(sheet); if (dbCellRecordPos == 252) { // The overt symptom of the bug // DBCELL record pos is1 calculated wrong if VRA comes before RRA throw new AssertionException("Identified bug 45145"); } Assert.AreEqual(242, dbCellRecordPos); }
public void TestMultipleBlanks() { BlankRecord brA2 = NewBlankRecord(0, 1); BlankRecord brB2 = NewBlankRecord(1, 1); BlankRecord brC2 = NewBlankRecord(2, 1); BlankRecord brD2 = NewBlankRecord(3, 1); BlankRecord brE2 = NewBlankRecord(4, 1); BlankRecord brB3 = NewBlankRecord(1, 2); BlankRecord brC3 = NewBlankRecord(2, 2); valueRecord.InsertCell(brA2); valueRecord.InsertCell(brB2); valueRecord.InsertCell(brD2); confirmMulBlank(3, 1, 1); valueRecord.InsertCell(brC3); confirmMulBlank(4, 1, 2); valueRecord.InsertCell(brB3); valueRecord.InsertCell(brE2); confirmMulBlank(6, 3, 0); valueRecord.InsertCell(brC2); confirmMulBlank(7, 2, 0); valueRecord.RemoveCell(brA2); confirmMulBlank(6, 2, 0); valueRecord.RemoveCell(brC2); confirmMulBlank(5, 2, 1); valueRecord.RemoveCell(brC3); confirmMulBlank(4, 1, 2); }
private BlankRecord NewBlankRecord(int col, int row) { BlankRecord blankRecord = new BlankRecord(); blankRecord.Row = (row); blankRecord.Column = ((short)col); return(blankRecord); }
public void TestInsertCell() { Assert.AreEqual(0, GetValueRecords().Count); BlankRecord blankRecord = NewBlankRecord(); valueRecord.InsertCell(blankRecord); Assert.AreEqual(1, GetValueRecords().Count); }
public void TestPhysicalNumberOfCells() { Assert.AreEqual(0, valueRecord.PhysicalNumberOfCells); BlankRecord blankRecord1 = NewBlankRecord(); valueRecord.InsertCell(blankRecord1); Assert.AreEqual(1, valueRecord.PhysicalNumberOfCells); valueRecord.RemoveCell(blankRecord1); Assert.AreEqual(0, valueRecord.PhysicalNumberOfCells); }
public void AddMultipleBlanks(MulBlankRecord mbr) { for (int j = 0; j < mbr.NumColumns; j++) { BlankRecord br = new BlankRecord(); br.Column = j + mbr.FirstColumn; br.Row = mbr.Row; br.XFIndex = (mbr.GetXFAt(j)); InsertCell(br); } }
public void TestInsertCell() { IEnumerator iterator = valueRecord.GetEnumerator(); Assert.IsFalse(iterator.MoveNext()); BlankRecord blankRecord = NewBlankRecord(); valueRecord.InsertCell(blankRecord); iterator = valueRecord.GetEnumerator(); Assert.IsTrue(iterator.MoveNext()); }
public void TestRemoveCell() { BlankRecord blankRecord1 = NewBlankRecord(); valueRecord.InsertCell(blankRecord1); BlankRecord blankRecord2 = NewBlankRecord(); valueRecord.RemoveCell(blankRecord2); Assert.AreEqual(0, GetValueRecords().Count); // removing an already empty cell just falls through valueRecord.RemoveCell(blankRecord2); }
public void TestRemoveCell() { BlankRecord blankRecord1 = NewBlankRecord(); valueRecord.InsertCell(blankRecord1); BlankRecord blankRecord2 = NewBlankRecord(); valueRecord.RemoveCell(blankRecord2); IEnumerator iterator = valueRecord.GetEnumerator(); Assert.IsFalse(iterator.MoveNext()); // removing an already empty cell just falls through valueRecord.RemoveCell(blankRecord2); }
private IList TestData() { IList records = new ArrayList(); FormulaRecord formulaRecord = new FormulaRecord(); //UnknownRecord unknownRecord = new UnknownRecord(); BlankRecord blankRecord = new BlankRecord(); WindowOneRecord windowOneRecord = new WindowOneRecord(); formulaRecord.Row = 1; formulaRecord.Column = 1; blankRecord.Row = 2; blankRecord.Column = 2; records.Add(formulaRecord); records.Add(blankRecord); records.Add(windowOneRecord); return(records); }
public void TestSheetDimensions() { InternalSheet sheet = InternalSheet.CreateSheet(); DimensionsRecord dimensions = (DimensionsRecord)sheet.FindFirstRecordBySid(DimensionsRecord.sid); Assert.AreEqual(0, dimensions.FirstCol); Assert.AreEqual(0, dimensions.FirstRow); Assert.AreEqual(1, dimensions.LastCol); // plus pne Assert.AreEqual(1, dimensions.LastRow); // plus pne RowRecord rr = new RowRecord(0); sheet.AddRow(rr); Assert.AreEqual(0, dimensions.FirstCol); Assert.AreEqual(0, dimensions.FirstRow); Assert.AreEqual(1, dimensions.LastCol); Assert.AreEqual(1, dimensions.LastRow); CellValueRecordInterface cvr; cvr = new BlankRecord(); cvr.Column = ((short)0); cvr.Row = (0); sheet.AddValueRecord(0, cvr); Assert.AreEqual(0, dimensions.FirstCol); Assert.AreEqual(0, dimensions.FirstRow); Assert.AreEqual(1, dimensions.LastCol); Assert.AreEqual(1, dimensions.LastRow); cvr = new BlankRecord(); cvr.Column = ((short)1); cvr.Row = (0); sheet.AddValueRecord(0, cvr); Assert.AreEqual(0, dimensions.FirstCol); Assert.AreEqual(0, dimensions.FirstRow); Assert.AreEqual(2, dimensions.LastCol); //YK: failed until Bugzilla 53414 was fixed Assert.AreEqual(1, dimensions.LastRow); }
/// <summary> /// Sets the cell type. The SetValue flag indicates whether to bother about /// trying to preserve the current value in the new record if one is Created. /// The SetCellValue method will call this method with false in SetValue /// since it will overWrite the cell value later /// </summary> /// <param name="cellType">Type of the cell.</param> /// <param name="setValue">if set to <c>true</c> [set value].</param> /// <param name="row">The row.</param> /// <param name="col">The col.</param> /// <param name="styleIndex">Index of the style.</param> private void SetCellType(CellType cellType, bool setValue, int row, int col, short styleIndex) { if (cellType > CellType.Error) { throw new Exception("I have no idea what type that Is!"); } switch (cellType) { case CellType.Formula: FormulaRecordAggregate frec = null; if (cellType != this.cellType) { frec = _sheet.Sheet.RowsAggregate.CreateFormula(row, col); } else { frec = (FormulaRecordAggregate)_record; } frec.Column = col; if (setValue) { frec.FormulaRecord.Value = NumericCellValue; } frec.XFIndex = styleIndex; frec.Row = row; _record = frec; break; case CellType.Numeric: NumberRecord nrec = null; if (cellType != this.cellType) { nrec = new NumberRecord(); } else { nrec = (NumberRecord)_record; } nrec.Column = col; if (setValue) { nrec.Value = NumericCellValue; } nrec.XFIndex = styleIndex; nrec.Row = row; _record = nrec; break; case CellType.String: LabelSSTRecord lrec = null; if (cellType != this.cellType) { lrec = new LabelSSTRecord(); } else { lrec = (LabelSSTRecord)_record; } lrec.Column = col; lrec.Row = row; lrec.XFIndex = styleIndex; if (setValue) { String str = ConvertCellValueToString(); int sstIndex = book.Workbook.AddSSTString(new UnicodeString(str)); lrec.SSTIndex = (sstIndex); UnicodeString us = book.Workbook.GetSSTString(sstIndex); stringValue = new HSSFRichTextString(); stringValue.UnicodeString = us; } _record = lrec; break; case CellType.Blank: BlankRecord brec = null; if (cellType != this.cellType) { brec = new BlankRecord(); } else { brec = (BlankRecord)_record; } brec.Column = col; // During construction the cellStyle may be null for a Blank cell. brec.XFIndex = styleIndex; brec.Row = row; _record = brec; break; case CellType.Boolean: BoolErrRecord boolRec = null; if (cellType != this.cellType) { boolRec = new BoolErrRecord(); } else { boolRec = (BoolErrRecord)_record; } boolRec.Column = col; if (setValue) { boolRec.SetValue(ConvertCellValueToBoolean()); } boolRec.XFIndex = styleIndex; boolRec.Row = row; _record = boolRec; break; case CellType.Error: BoolErrRecord errRec = null; if (cellType != this.cellType) { errRec = new BoolErrRecord(); } else { errRec = (BoolErrRecord)_record; } errRec.Column = col; if (setValue) { errRec.SetValue((byte)HSSFErrorConstants.ERROR_VALUE); } errRec.XFIndex = styleIndex; errRec.Row = row; _record = errRec; break; } if (cellType != this.cellType && this.cellType != CellType.Unknown) // Special Value to indicate an Uninitialized Cell { _sheet.Sheet.ReplaceValueRecord(_record); } this.cellType = cellType; }
private Biff GetCorrectRecord(GenericBiff record, Stream stream, SstRecord sst) { Biff ret = record; switch (record.Id) { case (ushort)RecordType.Bof: BofRecord bof = new BofRecord(record); if (bof.Version < 0x0600) { throw new Exception("Versions below Excel 97/2000 are currently not supported."); } ret = bof; break; case (ushort)RecordType.Boundsheet: ret = new BoundSheetRecord(record); break; case (ushort)RecordType.Index: ret = new IndexRecord(record); break; case (ushort)RecordType.DbCell: ret = new DbCellRecord(record); break; case (ushort)RecordType.Row: ret = new RowRecord(record); break; case (ushort)RecordType.Continue: ret = new ContinueRecord(record); break; case (ushort)RecordType.Blank: ret = new BlankRecord(record); break; case (ushort)RecordType.BoolErr: ret = new BoolErrRecord(record); break; case (ushort)RecordType.Formula: ret = new FormulaRecord(record, stream); break; case (ushort)RecordType.Label: ret = new LabelRecord(record); break; case (ushort)RecordType.LabelSst: ret = new LabelSstRecord(record, sst); break; case (ushort)RecordType.MulBlank: ret = new MulBlankRecord(record); break; case (ushort)RecordType.MulRk: ret = new MulRkRecord(record); break; case (ushort)RecordType.String: ret = new StringValueRecord(record); break; case (ushort)RecordType.Xf: ret = new XfRecord(record); break; case (ushort)RecordType.Rk: ret = new RkRecord(record); break; case (ushort)RecordType.Number: ret = new NumberRecord(record); break; case (ushort)RecordType.Array: ret = new ArrayRecord(record); break; case (ushort)RecordType.ShrFmla: ret = new SharedFormulaRecord(record); break; case (ushort)RecordType.Table: ret = new TableRecord(record); break; case (ushort)RecordType.Sst: ret = new SstRecord(record, stream); break; case (ushort)RecordType.Eof: ret = new EofRecord(record); break; case (ushort)RecordType.Font: ret = new FontRecord(record); break; case (ushort)RecordType.Format: ret = new Net.SourceForge.Koogra.Excel.Records.FormatRecord(record); break; case (ushort)RecordType.Palette: ret = new PaletteRecord(record); break; case (ushort)RecordType.Hyperlink: ret = new HyperLinkRecord(record); break; } return(ret); }