Downloading excel file with valid field format.
In my application, we have an option to download the excel file.
At implementation level :
Whenever a user clicks to download, the file data is retrieved from database and directly written into a excel file due to this all the data written into the file is in string format.
Excel file contains columns like date or amount. When user wants to have SUM/Avg of amount, then its not possible since the data type of amount is string instead of integer or float.
As per my knowledge, query accesses many tables and it will be difficult to retrieve data type of the each field selected.
Since, I know which are the fields will be written to a excel, I am thinking of hard coding the data type of the fields while writing to excel.
Most of the fields are of String data type (i.e Varchar and char).
Some fields are integer, currency and date.
We are using Java 1.4 and need to deal with multiple java files since we have different downloads.
1. Have a properties file with field names as value comma separated and data type as key.
2. Have a String with field names in the respective class.
So, whenever we retrieve data from data base we can check for the field names and compare these field values with the properties file (containing field names comma separated) and if matches, pass the key to a method which takes care of writing to a excel file.
Please let me know which is the better option or if any other option.