So I'm using C# with the NPOI package and trying to assign my file to to a XSSF workbook variable to be read and I'm getting the following error
here is the relevant code fragment
private static XSSFWorkbook workbook;
// runs the console, which runs the gogo()
public static void main(String[] args)
{
Console.run2();
}
public void gogo()
{
FileInputStream excelFile;
try
{
// get the file and assign it to excelFile
excelFile = new FileInputStream(new File(FileName.getFile()));
// open up the excelfile workbook
workbook = new XSSFWorkbook(excelFile);
// get the # of sheets in the workbook for iterator
this.lastSheet = workbook.getNumberOfSheets();
XSSFWorkbook
ctor accepts Stream
as its argument. However, FileInputStream
does not extend Stream
(nor is it implicitly convertible). One way to solve your issue is to use FileStream
instead of FileInputStream
. For example:
FileStream excelFile = File.OpenRead(FileName.getFile());