/** * 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 * * @param r the raw data */ protected RecordData(Record r) { record = r; code = r.getCode(); }
/** * Writes out the biff record * @param r * @exception IOException if an error occurs */ private bool writeRecord(CSharpJExcel.Jxl.Read.Biff.Record r, TextWriter os) { bool cont = true; int pos = reader.getPos(); int code = r.getCode(); if (bofs == 0) { cont = (r.getType() == CSharpJExcel.Jxl.Biff.Type.BOF); } if (!cont) { return(cont); } if (r.getType() == CSharpJExcel.Jxl.Biff.Type.BOF) { bofs++; } if (r.getType() == CSharpJExcel.Jxl.Biff.Type.EOF) { bofs--; } StringBuilder buf = new StringBuilder(); // Write out the record header writeSixDigitValue(pos, buf); buf.Append(" ["); buf.Append(recordNames[r.getType()]); buf.Append("]"); buf.Append(" (0x"); buf.Append(code.ToString("x")); buf.Append(")"); if (code == CSharpJExcel.Jxl.Biff.Type.XF.value) { buf.Append(" (0x"); buf.Append(xfIndex.ToString("x")); buf.Append(")"); xfIndex++; } if (code == CSharpJExcel.Jxl.Biff.Type.FONT.value) { if (fontIndex == 4) { fontIndex++; } buf.Append(" (0x"); buf.Append(fontIndex.ToString("x")); buf.Append(")"); fontIndex++; } os.Write(buf.ToString()); os.WriteLine(); byte[] standardData = new byte[4]; standardData[0] = (byte)(code & 0xff); standardData[1] = (byte)((code & 0xff00) >> 8); standardData[2] = (byte)(r.getLength() & 0xff); standardData[3] = (byte)((r.getLength() & 0xff00) >> 8); byte[] recordData = r.getData(); byte[] data = new byte[standardData.Length + recordData.Length]; Array.Copy(standardData, 0, data, 0, standardData.Length); Array.Copy(recordData, 0, data, standardData.Length, recordData.Length); int byteCount = 0; int lineBytes = 0; while (byteCount < data.Length) { buf = new StringBuilder(); writeSixDigitValue(pos + byteCount, buf); buf.Append(" "); lineBytes = Math.Min(bytesPerLine, data.Length - byteCount); for (int i = 0; i < lineBytes; i++) { writeByte(data[i + byteCount], buf); buf.Append(' '); } // Perform any padding if (lineBytes < bytesPerLine) { for (int i = 0; i < bytesPerLine - lineBytes; i++) { buf.Append(" "); } } buf.Append(" "); for (int i = 0; i < lineBytes; i++) { char c = (char)data[i + byteCount]; if (c < ' ' || c > 'z') { c = '.'; } buf.Append(c); } byteCount += lineBytes; os.Write(buf.ToString()); os.WriteLine(); } return(cont); }