我正在尝试将数据导出到Excel,并且正在使用StringBuffer追加列和行。我写了必要的列标题,然后在这些标题中填充值。我得到的日期类似于代码段中的内容。日期下的某些值是空的。因此,我面临的问题是,日期中的数据为空,单元格被视为空,并且值未放入正确的列中,我尝试检查null并添加一个0,但这不能正常工作好吧。
我不确定如何解决此问题。我想获取该日期列,例如,对于'require201809'列,如果存在值,则填充该值,否则将其留空。
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");
}
如果有人可以帮助我解决这个问题,或者至少给出一个关于如何解决这个问题的想法,我将非常有帮助。