In my current project I am doing a lot of Excel manipulation using Apache POI and Jacob COM libraries. One of the first challenges I faced was to write test cases that could read these Excel files and process them. This wasn’t rocket science, but I want to blog about this so that a. I can share my approach and b. So that I can use this blog post in case I want to do this in the future.
So my Excel file which I want to test is stored in /src/test/resources as Gantt_XLS.xls in a Maven setup.So here is my test case -
So in this code, I am reading a file in the test resources folder as a InputStream, writing the stream to a file in a unique directory in my OS’s temp directory and finally processing the file.
Now, the other task I am trying to do is converting a SpreadsheetML file to a binary Excel file. SpreadsheetML is MS Office Excel 2003 format for storing Excel files in XML format. For this I am using the Jacob COM library.