Example #1
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;
        }
Example #2
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;
        }