Error in creating workbook

Hello Team,

I am not able to read workbook downloaded from outlook mail through java. I am getting below exception while creating new workbook:
java.lang.NullPointerException
at com.aspose.cells.zalo.A(Unknown Source)
at com.aspose.cells.zalo.z(Unknown Source)
at com.aspose.cells.zalo.y(Unknown Source)
at com.aspose.cells.zalo.a(Unknown Source)
at com.aspose.cells.zalk.d(Unknown Source)
at com.aspose.cells.zalk.b(Unknown Source)
at com.aspose.cells.zalk.w(Unknown Source)
at com.aspose.cells.zalk.d(Unknown Source)
at com.aspose.cells.zalj.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)

I am using aspose cells 9.0.0 version. Please help.

@rst01,
Thank you for your query. It seems that you are not initializing the pointer to beginning of the stream. Ensure that you are handling the stream properly. If this is not the issue, please save the downloaded stream into a file and try to load it into workbook. If it raises some error, please share your runnable console application and downloaded stream in a file for our testing. We will analyze the data here and provide assistance accordingly.

@ahsaniqbalsidiqui sir we are using below code to download file and save it to our system from a link in a mail :

public boolean isFileDownloaded(String urlStr, String file) throws IOException {
	URL url = null;
	ReadableByteChannel readableByteChannel = null;
	FileOutputStream fileOutputStream = null;
	FileChannel fileChannel = null;
	File f = new File(file);
	try {
		url = new URL(urlStr);
		readableByteChannel = Channels.newChannel(url.openStream());
		fileOutputStream = new FileOutputStream(f);
		fileChannel = fileOutputStream.getChannel();
		fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);

}
}

Now when we are trying to create workbook for the downloaded file, we are getting exception mentioned in the first post.

private Worksheet getWorksheet(String fileName) {
//Workbook workbook = null;

	//File path = new File(FILE_LOCATION);
	Workbook workbook = null;
	Worksheet worksheet = null;

	try {
		InputStream fis = new ByteArrayInputStream(FileUtils.readFileToByteArray(new File(FILE_LOCATION + fileName))); 
		//workbook = new Workbook(fis);
		LoadOptions ls = new LoadOptions(LoadFormat.ODS);
		workbook = new Workbook(FILE_LOCATION + fileName/* .substring(0,fileName.lastIndexOf("."))*/,ls );
		/*
		 * 
		 * 
		 * Worksheet worksheet = null; log.info("create worksheet from bytes"); try {
		 * Workbook workbook = new Workbook(fileName);
		 */
		worksheet = workbook.getWorksheets().get(0);
	} catch (IOException ex) {
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return worksheet;
}

We checked and the file pointer is at zero position as it should be.

@rst01,
Thank you for sharing code snippet which is although not a runnable console application as requested in the previous post. However, the sample file is must required to reproduce the issue here. Please save the stream to some file along with the valid file extension and attach here with the thread for our testing. We will use it to reproduce the issue here and provide our feedback.