下午好,我正在尝试上一堂课,如果一个人擅长并再写一行。
但是我不太了解行和列的工作方式,因此行不通。
有人可以在代码中帮助我吗?
public class ReadCSV{
public static void main( String [] args ) {
//This worksheet has 5 sample lines and is in csv.
String csvFile = "C:\\Users\\Desktop\\test3.csv";
BufferedReader br = null;
String cvsSplitBy = ",";
String transformeisso = "";
try {
br = new BufferedReader(new FileReader(csvFile));
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Arquivo");
sheet.setColumnWidth(0, 6000);
sheet.setColumnWidth(1, 4000);
int i = 0;
while (br.readLine() != null && !br.readLine().equals("") ) {
String line = br.readLine();
String[] coluna = line.split(cvsSplitBy);
if(coluna.length > 1 ) {
transformeisso = coluna[3];
}
String str = transformeisso.replaceAll("\"", "");
//Transform Here's this getemail method to get the email from a string and add in a new column at the end of excel
String emails = getemail (str);
Row header = sheet.createRow(i);
Cell headerCell = header.createCell(i);
headerCell.setCellValue(line);
Cell headerCellEmail = header.createCell(i+1);
headerCellEmail.setCellValue(emails);
i++;
}
File currDir = new File("C:\\temp");
String path = currDir.getAbsolutePath();
String fileLocation = path.substring(0, path.length() - 1) + "new.xlsx";
FileOutputStream outputStream = new FileOutputStream(fileLocation);
workbook.write(outputStream);
workbook.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
}
我将其留在此处,这是excel条目以及我希望它如何作为输出的地方。 从字符串中删除电子邮件的方法效果很好...问题我认为这是行和列的计数,我不太了解它是如何工作的... 请帮助我
这有多出色?
https://uploaddeimagens.com.br/imagens/2-png-86fae7f1-9432-46ff-8d01-08de16ac0518
如何保持卓越水平
https://uploaddeimagens.com.br/imagens/1-png-abd02d01-3518-474e-8f80-b97b10db02d6
TKS !!!