/** * 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); }
/// <summary> A factory method which takes in an excel file and reads in the contents. /// /// </summary> /// <exception cref=""> IOException /// </exception> /// <exception cref=""> BiffException /// </exception> /// <param name="filename">the excel 97 spreadsheet to parse /// </param> /// <param name="ws">the settings for the workbook /// </param> /// <returns> a workbook instance /// </returns> public static Workbook getWorkbook(string filename, WorkbookSettings ws) { FileStream fis = new FileStream(filename, FileMode.Open, FileAccess.Read); // Always close down the input stream, regardless of whether or not the // file can be parsed. Thanks to Steve Hahn for this NExcel.Read.Biff.File dataFile = null; try { dataFile = new NExcel.Read.Biff.File(fis, ws); } catch (Exception e) { fis.Close(); throw e; } fis.Close(); Workbook workbook = new WorkbookParser(dataFile, ws); workbook.parse(); return(workbook); }
/** * 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); }
/// <summary> A factory method which takes in an excel file and reads in the contents. /// /// </summary> /// <exception cref=""> IOException /// </exception> /// <exception cref=""> BiffException /// </exception> /// <param name="is">an open stream which is the the excel 97 spreadsheet to parse /// </param> /// <param name="ws">the settings for the workbook /// </param> /// <returns> a workbook instance /// </returns> public static Workbook getWorkbook(Stream stream, WorkbookSettings ws) { NExcel.Read.Biff.File dataFile = new NExcel.Read.Biff.File(stream, ws); Workbook workbook = new WorkbookParser(dataFile, ws); workbook.parse(); return(workbook); }