Bonjour je n'arrive pas à utiliser la fonction replace ...
En fait je crois que j'ai un problème car le type de la variable est HSSFCell.
C'est ça qui doit poser problème.
Je mets le code :
Après avoir utilisé la fonction, j'affiche le résultat mais rien n'a changé en fait ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package tests; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; public class CopyOfProgramme_final { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("C:/test2/workbook.xls")); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0); HSSFRow row = sheet.getRow(2); HSSFCell cell = row.getCell((short)3); if (cell == null) cell = row.createCell((short)3); cell.setCellType(HSSFCell.CELL_TYPE_STRING); String cell2 = (cell.getStringCellValue()); cell2.replace('e','a'); System.out.println(cell); System.out.println(cell2); } }
Merci d'avance
Partager