0

I do a database search, assemble the columns and export a txt

But in the column ("aaun_md_area) that is a number, instead of a comma, a dot is being applied, making it difficult to count in excel.

The column that is decimal that I need to change, is the "aaun_md_area" column

How to export using a comma?

File arquivo = new File(path);
 try (FileWriter fw = new FileWriter(arquivo))
    { fw.append("Witdh");
      fw.append("Area");
    }

for (int i = 0;i<listaRt.length; i++){
  rts.add(listaRt[i]);
  ResultSet resultSigiop = stSigiop.executeQuery(sqlSigiop.replace(":1", 
  rts.toString().replace("[", "").replace("]", "")));
       while(resultSigiop.next()) 
            {
               fw.append(resultSigiop.getString("ssrt_cd_status_subitem_rt"));
               fw.append('\t');
               fw.append(resultSigiop.getString("aaun_md_area"));
               fw.append('\n'); 
            }
                fw.flush();
                
            } catch(IOException ex){
                throw ex;
            }
            
            rts = new ArrayList<String>();
        }   
        
        fw.close();
        
    }
    catch(IOException ex){
        throw ex;
    }
    
}
AllPower
  • 175
  • 1
  • 4
  • 16
  • 2
    You can use this answer to set whatever decimal separator you need [How to change the decimal separator of DecimalFormat from comma to dot/point?](https://stackoverflow.com/questions/5054132/how-to-change-the-decimal-separator-of-decimalformat-from-comma-to-dot-point) – Abhijit Sarkar May 17 '23 at 17:24
  • 2
    `resultSigiop.getString("aaun_md_area")` should probably be `resultSigiop.getDouble("aaun_md_area")`. You are reading the value as a String from the database and writing that String straight to the file. – Elliott Frisch May 17 '23 at 17:30

1 Answers1

0

You could use the String.replace method, replacing a . with a ,.

fw.append(resultSigiop.getString("aaun_md_area").replace('.', ','));
Reilas
  • 3,297
  • 2
  • 4
  • 17