0

在excel,我要拿到12.20, 可是拿到12.2
有什麼方法可以讓excel file 在最後一個位數放 0 ?

 public void write(List<? extends List> list) throws Exception {

            if (list != null) {
                try {
                    writeFile(header(), detail(list.get(0)));
                } catch (BatchRunException ex) {
                    throw new BatchRunException(" Fail..." + ex);
                }
            }
        }

 private void writeFile(String header, List<String> detail) throws IOException, BatchRunException {

        String fullPath = outputPath + fileNameFormat;

        File file = new File(fullPath);
        File path = new File(outputPath);

        if (!path.exists()) {
            path.mkdirs();
        }

        if (!file.exists()) {
            file.createNewFile();
        }

        try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {
            bw.write(header);
            bw.write(NEW_LINE);

            for (String s : detail) {

                bw.write(s);
                bw.write(NEW_LINE);
            }


        } catch (IOException ex) {
            throw new BatchRunException(" Fail..." + ex);
        }
    }

    private String header() {
        StringBuilder bf = new StringBuilder();

        bf.append("Employee Name").append(SEPERATOR);
        bf.append("Amount").append(SEPERATOR);
        return bf.toString();
    }

    private List<String> detail(List<SettlementList> dList) {
        List<String> list = new ArrayList();
        BigDecimal a = new BigDecimal("0");

        for (SettlementList s : dList) {
            StringBuilder bf = new StringBuilder();

            bf.append(s.Name()).append(SEPERATOR);
            bf.append(s.getNetAmount()).append(SEPERATOR); // here the error
            list.add(bf.toString());    
        }

        return list;
    }

撰写答案