private void CreateFilterModeRecord(HSSFSheet sheet, int insertPos) { //look for the FilterModeRecord Npoi.Core.HSSF.Record.Record record = sheet.Sheet.FindFirstRecordBySid(FilterModeRecord.sid); // this local variable hides the class one: FilterModeRecord filtermode; //if not found, add a new one if (record == null) { filtermode = new FilterModeRecord(); sheet.Sheet.Records.Insert(insertPos, filtermode); } }
/** * @return the number of {@link SharedFormulaRecord}s encoded for the specified sheet */ private static int countSharedFormulas(ISheet sheet) { Npoi.Core.HSSF.Record.Record[] records = RecordInspector.GetRecords(sheet, 0); int count = 0; for (int i = 0; i < records.Length; i++) { Npoi.Core.HSSF.Record.Record rec = records[i]; if (rec is SharedFormulaRecord) { count++; } } return(count); }
private void CreateAutoFilterInfoRecord(HSSFSheet sheet, int insertPos, Area3DPtg ptg) { //look for the AutoFilterInfo Record Npoi.Core.HSSF.Record.Record record = sheet.Sheet.FindFirstRecordBySid(AutoFilterInfoRecord.sid); AutoFilterInfoRecord info; if (record == null) { info = new AutoFilterInfoRecord(); sheet.Sheet.Records.Insert(insertPos, info); } else { info = record as AutoFilterInfoRecord; } info.NumEntries = (short)(ptg.LastColumn - ptg.FirstColumn + 1); }
private static byte[] toByteArray(List <RecordBase> records) { MemoryStream out1 = new MemoryStream(); foreach (RecordBase rb in records) { Npoi.Core.HSSF.Record.Record r = (Npoi.Core.HSSF.Record.Record)rb; try { byte[] data = r.Serialize(); out1.Write(data, 0, data.Length); } catch (IOException e) { throw new RuntimeException(e); } } return(out1.ToArray()); }
public void TestDuplicatePLS_bug47415() { Npoi.Core.HSSF.Record.Record plsA = ur(UnknownRecord.PLS_004D, "BA AD F0 0D"); Npoi.Core.HSSF.Record.Record plsB = ur(UnknownRecord.PLS_004D, "DE AD BE EF"); Npoi.Core.HSSF.Record.Record contB1 = new ContinueRecord(HexRead.ReadFromString("FE ED")); Npoi.Core.HSSF.Record.Record contB2 = new ContinueRecord(HexRead.ReadFromString("FA CE")); Npoi.Core.HSSF.Record.Record[] recs = { new HeaderRecord("&LSales Figures"), new FooterRecord("&LInventory"), new HCenterRecord(), new VCenterRecord(), plsA, plsB, contB1, contB2, // make sure continuing PLS is still OK }; RecordStream rs = new RecordStream((recs), 0); PageSettingsBlock psb; try { psb = new PageSettingsBlock(rs); } catch (RecordFormatException e) { if ("Duplicate PageSettingsBlock record (sid=0x4d)".Equals(e.Message)) { throw new AssertionException("Identified bug 47415"); } throw e; } // serialize the PSB to see what records come out RecordInspector.RecordCollector rc = new RecordInspector.RecordCollector(); psb.VisitContainedRecords(rc); Npoi.Core.HSSF.Record.Record[] outRecs = rc.Records; // records were assembled in standard order, so this simple check is OK Assert.IsTrue(Arrays.Equals(recs, outRecs)); }
public void VisitRecord(Npoi.Core.HSSF.Record.Record r) { container.Add((RecordBase)r); }