[英]Display complete jtextarea content into single cell of excel file during export.
[英]How to save complete data of JTextArea in to single cell of csv file
我將JTextArea數據保存到csv文件中,但是應用程序未將整個數據保存在單個單元格中。
例如:在JTextArea中,我添加了如下數據
apple
mango
banana
guava
在.csv文件中,它保存為四行而不是單行。
下面是我的代碼如何iam保存數據。
String address ;
address = textArea.getText();
writer.append(address);
writer.append(',');
誰能建議如何解決這個問題?
謝謝
為什么不用逗號替換JTextArea
的換行符,以便給您一個CSV行:
writer.append(address.replace("\n", ","));
輸出:
apple,mango,banana,guava
writer.append(address.replace("\n", "-"));
Use character other than ",". If not, data will be placed in consecutive cell of the same row
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.