簡體   English   中英

如何在 CSV 文件中的特定單元格中寫入?

[英]How to write in specific cell in a CSV file?

我需要使用org.apache.commons.csv庫在.csv文件中的特定單元格中寫入並復制所有行。

我試過這個:

Reader reader = Files.newBufferedReader(Paths.get(Properties.dataFilePath));
CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT);
List<CSVRecord> records = csvParser.getRecords();
records.get(rowNumber)[columnIndex] = value;

但是,這是不允許的。

編輯 1

我的 IDE 提到: The type of the expression must be an array type but it resolved to CSVRecord

你試過value = records.get(rowNumber).get(columnIndex); ?

看看這里,它可能會對你有所幫助: https://commons.apache.org/proper/commons-csv/apidocs/org/apache/commons/csv/CSVRecord.ZFC35FDC70D5FC69D2569E8C

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM