I am trying to export data to an excel and I am using StringBuffer to append columns and rows. I wrote the necessary column headers and to these headers I am populating the values. I get the dates like in the code snippet. The some of the values under the dates are null. So, I am facing a problem in having the empty data for the dates, the cell is treated as empty and the values are not getting placed into the right column, I tried checking for null and adding a 0 instead but that did not work as well.
I am not sure how I can tackle this problem. I want to get that particulat date column, for example, for column 'require201809' if a value exists then populate that value else leave it empty.
StringBuffer strBf = new StringBuffer();
strBf.append("BW");
for (String date : sortedOrderedDates) {
strBf.append(";require" + date);
strBf.append(";free" + date);
}
strBf.append("\n");
for (String skulId : pro.getSkulGrMap().keySet()) {
strBf.append(pro.getBWId());
strBf.append(";");
for (String dateKey : productData.get(skulId).getOrderAmount().keySet()) {
if(productData.get(skulId).getOrderAmount().get(dateKey)== null){
strBf.append("0");
strBf.append(";");
}else{
strBf.append(productData.get(skulId).getOrderAmount().get(dateKey));
strBf.append(";");
}
if(productData.get(skulId).getProductAmount().get(dateKey) != null){
strBf.append(productData.get(skulId).getProductAmount().get(dateKey));
strBf.append(";");
}else{
strBf.append("0");
strBf.append(";");
}
}
strBf.append("\n");
}
I would be really helpful if someone can help me with this or atleast give an idea as to how I can tackle this.