예제 #1
0
        /**
         * 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++;
                }
            }
        }
예제 #2
0
        /**
         * A factory method which takes input an excel file and reads input the contents.
         *
         * @param inStream an open stream which inStream the the excel 97 spreadsheet to parse
         * @param ws the settings for the workbook
         * @return a workbook instance
         * @exception IOException
         * @exception BiffException
         */
        public static Workbook getWorkbook(Stream inStream, WorkbookSettings ws)
        {
            CSharpJExcel.Jxl.Read.Biff.File dataFile = new CSharpJExcel.Jxl.Read.Biff.File(inStream,ws);

            Workbook workbook = new WorkbookParser(dataFile,ws);
            workbook.parse();

            return workbook;
        }
예제 #3
0
        /**
         * A factory method which takes input an excel file and reads input the contents.
         *
         * @exception IOException
         * @exception BiffException
         * @param file the excel 97 spreadsheet to parse
         * @param ws the settings for the workbook
         * @return a workbook instance
         */
        public static Workbook getWorkbook(FileInfo file,WorkbookSettings ws)
        {
            Stream fis = new FileStream(file.FullName,FileMode.Open);

            // Always close down the input stream, regardless of whether or not the
            // file can be parsed.  Thanks to Steve Hahn for this
            CSharpJExcel.Jxl.Read.Biff.File dataFile = null;

            try
                {
                dataFile = new CSharpJExcel.Jxl.Read.Biff.File(fis, ws);
                }
            catch (IOException e)
                {
                throw e;
                }
            catch (BiffException e)
                {
                throw e;
                }
            finally
                {
                fis.Close();
                }

            Workbook workbook = new WorkbookParser(dataFile,ws);
            workbook.parse();

            return workbook;
        }
예제 #4
0
 /**
  * Constructor
  *
  * @param fr the formatting records
  * @param sst the shared string table
  * @param f the excel file
  * @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 wp the workbook which this sheet belongs to
  * @param sp the start position of the sheet bof in the excel file
  * @param sh the sheet
  * @param nf 1904 date record flag
  * @exception BiffException
  */
 public SheetReader(File f,
     SSTRecord sst,
     FormattingRecords fr,
     BOFRecord sb,
     BOFRecord wb,
     bool nf,
     WorkbookParser wp,
     int sp,
     SheetImpl sh)
 {
     excelFile = f;
     sharedStrings = sst;
     formattingRecords = fr;
     sheetBof = sb;
     workbookBof = wb;
     columnInfosArray = new ArrayList();
     sharedFormulas = new ArrayList();
     hyperlinks = new ArrayList();
     conditionalFormats = new ArrayList();
     rowProperties = new ArrayList(10);
     charts = new ArrayList();
     drawings = new ArrayList();
     outOfBoundsCells = new ArrayList();
     nineteenFour = nf;
     workbook = wp;
     startPosition = sp;
     sheet = sh;
     settings = new SheetSettings(sh);
     workbookSettings = workbook.getSettings();
 }