These questions do not really have anything to do with POI but are simply
Java programing questions. As such, you should not really ask them on this
list as it's purpose is to answer questions that relate to the use of the
POI api.

Having said that, you will need to find some way to distinguish between the
files and then process accordingly. You have a few options;

1. Create a 'factory' class that can determine which clients sheets you are
processing and then load code that is optimised to handle that data. This is
the way that the WorkbookFactory.create() method works, it establishes which
type of workbook is to be processed and instantiates either an HSSF or
XSSFWorkbook object. This technique relies upon you creating classes
optimised for processing each diffrerent clients data. The technique usually
adopted is to create an interface that has all of the necessary methods
declared on it. The different processing classes all implement the interface
and provide bodies for the methods. You then write code that uses the
interface classes and takes advantage of a Java language feature called
runtime polymorphism. It is this that allows me to write;

Workbook workbook = WorkbookFactory.create(new FileInputStream(new
File("Book1.xls")));
workbook.createSheet("Sheet One");

Or

Workbook workbook = WorkbookFactory.create(new FileInputStream(new
File("Book1.xlsx")));
workbook.createSheet("Sheet One");

and know that any methods I call will be directed to the correct object - an
HSSFWorkbook in the first case and an XSSFWorkbook in the second - even
though I seem to be interacting with the Workbook interface.

2. Write your properties class so that it contains a series of different
patterns. Then, your code should work out which clients sheets you are
processing and access the appropriate property. Imagine for example, you
have to process workbooks from Boots and Raleigh (two larger companies over
here). Your properties file could contains two entries;

boots_row_pattern=......
raleigh_row_pattern=.......

Your application would load the properties, determine which clients data was
being processed and either access the boots or raleigh row pattern
information using the appropriate key. This depends upon the finer details
of the process, do you need, for example to check every cell in the row for
both clients? If the basic processing is identical and only the patterns
differ, this is the better option to my mind as you will only have to
maintain a single code-base.

Yours

Mark B
-- 
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/How-to-check-if-Excel-values-are-matching-with-my-format-tp3379567p3386277.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to