/** * Constructor * * @param offset the offset in the raw file * @param f the excel 97 biff file * @param d the data record */ public Record(byte[] d, int offset, File f) { code = IntegerHelper.getInt(d[offset], d[offset + 1]); length = IntegerHelper.getInt(d[offset + 2], d[offset + 3]); file = f; file.skip(4); dataPos = f.getPos(); file.skip(length); type = Type.getType(code); }
/** * Constructs this number * * @param t the data * @param excelFile the excel biff data * @param v the value * @param fr the formatting records * @param es the external sheet * @param nt the name table * @param si the sheet */ public SharedBooleanFormulaRecord(Record t, File excelFile, bool v, FormattingRecords fr, ExternalSheet es, WorkbookMethods nt, SheetImpl si) : base(t, fr, es, nt, si, excelFile.getPos()) { value = v; }
/** * Constructs this string formula * * @param t the record * @param excelFile the excel file * @param fr the formatting record * @param es the external sheet * @param nt the workbook * @param si the sheet * @param dummy the overload indicator */ public SharedStringFormulaRecord(Record t, File excelFile, FormattingRecords fr, ExternalSheet es, WorkbookMethods nt, SheetImpl si, EmptyString dummy) : base(t, fr, es, nt, si, excelFile.getPos()) { value = string.Empty; }
/** * Constructs this number * * @param t the data * @param excelFile the excel biff data * @param v the errorCode * @param fr the formatting records * @param es the external sheet * @param nt the name table * @param si the sheet */ public SharedErrorFormulaRecord(Record t, File excelFile, int ec, FormattingRecords fr, ExternalSheet es, WorkbookMethods nt, SheetImpl si) : base(t, fr, es, nt, si, excelFile.getPos()) { errorCode = ec; }
/** * Constructs this number * * @param t the data * @param excelFile the excel biff data * @param v the value * @param fr the formatting records * @param es the external sheet * @param nt the name table * @param si the sheet */ public SharedNumberFormulaRecord(Record t, File excelFile, double v, FormattingRecords fr, ExternalSheet es, WorkbookMethods nt, SheetImpl si) : base(t, fr, es, nt, si, excelFile.getPos()) { value = v; format = defaultFormat; // format is set up later from the // SharedFormulaRecord }
/** * Constructor * * @param f the excel file * @param sst the shared string table * @param fr formatting records * @param sb the bof record which indicates the start of the sheet * @param wb the bof record which indicates the start of the sheet * @param nf the 1904 flag * @param wp the workbook which this sheet belongs to * @exception BiffException */ public SheetImpl(File f, SSTRecord sst, FormattingRecords fr, BOFRecord sb, BOFRecord wb, bool nf, WorkbookParser wp) { excelFile = f; sharedStrings = sst; formattingRecords = fr; sheetBof = sb; workbookBof = wb; columnInfosArray = new ArrayList(); sharedFormulas = new ArrayList(); hyperlinks = new ArrayList(); rowProperties = new ArrayList(10); columnInfosInitialized = false; rowRecordsInitialized = false; nineteenFour = nf; workbook = wp; workbookSettings = workbook.getSettings(); // Mark the position in the stream, and then skip on until the end startPosition = f.getPos(); if (sheetBof.isChart()) { // Set the start pos to include the bof so the sheet reader can handle it startPosition -= (sheetBof.getLength() + 4); } Record r = null; int bofs = 1; while (bofs >= 1) { r = f.next(); // use this form for quick performance if (r.getCode() == Type.EOF.value) { bofs--; } if (r.getCode() == Type.BOF.value) { bofs++; } } }
/** * Constructs this object from the raw data. We need to use the excelFile * to retrieve the string record which follows this formula record * * @param t the raw data * @param excelFile the excel file * @param fr the formatting records * @param es the external sheet records * @param nt the workbook * @param si the sheet impl * @param ws the workbook settings */ public StringFormulaRecord(Record t, File excelFile, FormattingRecords fr, ExternalSheet es, WorkbookMethods nt, SheetImpl si, WorkbookSettings ws) : base(t, fr, si) { externalSheet = es; nameTable = nt; data = getRecord().getData(); int pos = excelFile.getPos(); // Look for the string record in one of the records after the // formula. Put a cap on it to prevent looping Record nextRecord = excelFile.next(); int count = 0; while (nextRecord.getType() != Type.STRING && count < 4) { nextRecord = excelFile.next(); count++; } Assert.verify(count < 4, " @ " + pos); byte[] stringData = nextRecord.getData(); // Read in any continuation records nextRecord = excelFile.peek(); while (nextRecord.getType() == Type.CONTINUE) { nextRecord = excelFile.next(); // move the pointer within the data byte[] d = new byte[stringData.Length + nextRecord.getLength() - 1]; System.Array.Copy(stringData, 0, d, 0, stringData.Length); System.Array.Copy(nextRecord.getData(), 1, d, stringData.Length, nextRecord.getLength() - 1); stringData = d; nextRecord = excelFile.peek(); } readString(stringData, ws); }
/** * Constructs this string formula * * @param t the record * @param excelFile the excel file * @param fr the formatting record * @param es the external sheet * @param nt the workbook * @param si the sheet * @param ws the workbook settings */ public SharedStringFormulaRecord(Record t, File excelFile, FormattingRecords fr, ExternalSheet es, WorkbookMethods nt, SheetImpl si, WorkbookSettings ws) : base(t, fr, es, nt, si, excelFile.getPos()) { int pos = excelFile.getPos(); // Save the position in the excel file int filepos = excelFile.getPos(); // Look for the string record in one of the records after the // formula. Put a cap on it to prevent ednas Record nextRecord = excelFile.next(); int count = 0; while (nextRecord.getType() != Type.STRING && count < 4) { nextRecord = excelFile.next(); count++; } Assert.verify(count < 4, " @ " + pos); byte[] stringData = nextRecord.getData(); // Read in any continuation records nextRecord = excelFile.peek(); while (nextRecord.getType() == Type.CONTINUE) { nextRecord = excelFile.next(); // move the pointer within the data byte[] d = new byte[stringData.Length + nextRecord.getLength() - 1]; System.Array.Copy(stringData, 0, d, 0, stringData.Length); System.Array.Copy(nextRecord.getData(), 1, d, stringData.Length, nextRecord.getLength() - 1); stringData = d; nextRecord = excelFile.peek(); } int chars = IntegerHelper.getInt(stringData[0], stringData[1]); bool unicode = false; int startpos = 3; if (stringData.Length == chars + 2) { // string might only consist of a one byte length indicator, instead // of the more normal 2 startpos = 2; unicode = false; } else if (stringData[2] == 0x1) { // unicode string, two byte length indicator startpos = 3; unicode = true; } else { // ascii string, two byte length indicator startpos = 3; unicode = false; } if (!unicode) { value = StringHelper.getString(stringData, chars, startpos, ws); } else { value = StringHelper.getUnicodeString(stringData, chars, startpos); } // Restore the position in the excel file, to enable the SHRFMLA // record to be picked up excelFile.setPos(filepos); }