Although I defined the amount values as Double
in Java file, these values seem to be typed as String
in the exported Excel file. So, how can I force these values to be exported as Number
instead of String
? Is there a special method to be used ind sub.put(...), etc?
Java Class:
import java.io.Serializable;
import tr.com.cs.utility.Utility;
public class FinancePaymentList implements Serializable{
private static final long serialVersionUID = 5987846930239863477L;
private String oid;
private Double amount;
//... other properties
public void setAmountDue(Double amount) {
this.amountDue = amountDue;
}
}
JSON:
public static String jsonListToExcel (Collection<FinancePaymentList> list) throws TrnaspException {
try {
JSONObject obj = new JSONObject();
JSONArray array = new JSONArray();
for (FinancePaymentList form : list) {
JSONObject sub = new JSONObject();
sub.put("oid", form.getOid());
sub.put("amount", form.getAmount());
//... other properties
array.put(sub);
}
obj.put("data", array);
return obj.toString();
} catch (Exception e) {
throw new TrnaspException(e);
}
}