public void TestAutoFilter() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sh = (HSSFSheet)wb.CreateSheet(); InternalWorkbook iwb = wb.Workbook; InternalSheet ish = sh.Sheet; Assert.IsNull(iwb.GetSpecificBuiltinRecord(NameRecord.BUILTIN_FILTER_DB, 1)); Assert.IsNull(ish.FindFirstRecordBySid(AutoFilterInfoRecord.sid)); CellRangeAddress range = CellRangeAddress.ValueOf("A1:B10"); sh.SetAutoFilter(range); NameRecord name = iwb.GetSpecificBuiltinRecord(NameRecord.BUILTIN_FILTER_DB, 1); Assert.IsNotNull(name); // The built-in name for auto-filter must consist of a single Area3d Ptg. Ptg[] ptg = name.NameDefinition; Assert.AreEqual(1, ptg.Length, "The built-in name for auto-filter must consist of a single Area3d Ptg"); Assert.IsTrue(ptg[0] is Area3DPtg, "The built-in name for auto-filter must consist of a single Area3d Ptg"); Area3DPtg aref = (Area3DPtg)ptg[0]; Assert.AreEqual(range.FirstColumn, aref.FirstColumn); Assert.AreEqual(range.FirstRow, aref.FirstRow); Assert.AreEqual(range.LastColumn, aref.LastColumn); Assert.AreEqual(range.LastRow, aref.LastRow); // verify AutoFilterInfoRecord AutoFilterInfoRecord afilter = (AutoFilterInfoRecord)ish.FindFirstRecordBySid(AutoFilterInfoRecord.sid); Assert.IsNotNull(afilter); Assert.AreEqual(2, afilter.NumEntries); //filter covers two columns HSSFPatriarch dr = (HSSFPatriarch)sh.DrawingPatriarch; Assert.IsNotNull(dr); HSSFSimpleShape comboBoxShape = (HSSFSimpleShape)dr.Children[0]; Assert.AreEqual(comboBoxShape.ShapeType, HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX); Assert.IsNull(ish.FindFirstRecordBySid(ObjRecord.sid)); // ObjRecord will appear after serializetion wb = HSSFTestDataSamples.WriteOutAndReadBack(wb); sh = (HSSFSheet)wb.GetSheetAt(0); ish = sh.Sheet; ObjRecord objRecord = (ObjRecord)ish.FindFirstRecordBySid(ObjRecord.sid); IList subRecords = objRecord.SubRecords; Assert.AreEqual(3, subRecords.Count); Assert.IsTrue(subRecords[0] is CommonObjectDataSubRecord); Assert.IsTrue(subRecords[1] is FtCblsSubRecord); // must be present, see Bug 51481 Assert.IsTrue(subRecords[2] is LbsDataSubRecord); }
public void TestDgContainerMustBeRootOfHSSFSheetEscherRecords() { HSSFWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("47251.xls"); HSSFSheet sh = wb.GetSheetAt(0) as HSSFSheet; InternalSheet ish = HSSFTestHelper.GetSheetForTest(sh); List <RecordBase> records = ish.Records; // records to be aggregated List <RecordBase> dgRecords = records.GetRange(19, 23 - 19); byte[] dgBytes = toByteArray(dgRecords); IDrawing d = sh.DrawingPatriarch; EscherAggregate agg = (EscherAggregate)ish.FindFirstRecordBySid(EscherAggregate.sid); Assert.AreEqual(true, agg.EscherRecords[0] is EscherContainerRecord); Assert.AreEqual(EscherContainerRecord.DG_CONTAINER, agg.EscherRecords[0].RecordId); Assert.AreEqual((short)0x0, agg.EscherRecords[0].Options); agg = (EscherAggregate)ish.FindFirstRecordBySid(EscherAggregate.sid); byte[] dgBytesAfterSave = agg.Serialize(); Assert.AreEqual(dgBytes.Length, dgBytesAfterSave.Length, "different size of drawing data before and after save"); Assert.IsTrue(Arrays.Equals(dgBytes, dgBytesAfterSave), "drawing data before and after save is different"); }
public void TestWSBool() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = (HSSFSheet)wb.CreateSheet(); InternalSheet sheet = s.Sheet; WSBoolRecord record = (WSBoolRecord)sheet.FindFirstRecordBySid(WSBoolRecord.sid); // Check defaults Assert.AreEqual(false, record.AlternateExpression); Assert.AreEqual(false, record.AlternateFormula); Assert.AreEqual(false, record.Autobreaks); Assert.AreEqual(false, record.Dialog); Assert.AreEqual(false, record.DisplayGuts); Assert.AreEqual(true, record.FitToPage); Assert.AreEqual(false, record.RowSumsBelow); Assert.AreEqual(false, record.RowSumsRight); // Alter s.AlternativeExpression = (false); s.AlternativeFormula = (false); s.Autobreaks = true; s.Dialog = true; s.DisplayGuts = true; s.FitToPage = false; s.RowSumsBelow = true; s.RowSumsRight = true; // Check Assert.AreEqual(false, record.AlternateExpression); Assert.AreEqual(false, record.AlternateFormula); Assert.AreEqual(true, record.Autobreaks); Assert.AreEqual(true, record.Dialog); Assert.AreEqual(true, record.DisplayGuts); Assert.AreEqual(false, record.FitToPage); Assert.AreEqual(true, record.RowSumsBelow); Assert.AreEqual(true, record.RowSumsRight); Assert.AreEqual(false, s.AlternativeExpression); Assert.AreEqual(false, s.AlternativeFormula); Assert.AreEqual(true, s.Autobreaks); Assert.AreEqual(true, s.Dialog); Assert.AreEqual(true, s.DisplayGuts); Assert.AreEqual(false, s.FitToPage); Assert.AreEqual(true, s.RowSumsBelow); Assert.AreEqual(true, s.RowSumsRight); }
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); }