Révision 2943

tmp/org.txm.libs.msoffice/src/org/txm/libs/msoffice/ReadExcel.java (revision 2943)
8 8
import java.util.ArrayList;
9 9
import java.util.Arrays;
10 10
import java.util.HashMap;
11
import java.util.HashSet;
12 11
import java.util.List;
13 12

  
14 13
import org.apache.poi.EncryptedDocumentException;
......
151 150
	 * @throws InvalidFormatException
152 151
	 * @throws IOException
153 152
	 */
154
	public boolean copyColumns(HashMap<String, String> columnsToCopy) throws EncryptedDocumentException, InvalidFormatException, IOException {
153
	public boolean copyColumns(HashMap<String, String[]> columnsToCopy) throws EncryptedDocumentException, InvalidFormatException, IOException {
155 154
		Row headers = ws.getRow(0);
156 155
		if (headers == null) return false;
157 156
		
......
186 185
			
187 186
			int icol = 0;
188 187
			for (String col : columnsToCopy.keySet()) {
189
				int colIndex = searchColumns.get(col);
190
				
191
				Cell cell = row.getCell(colIndex);
192
				if (cell != null) {
193
					Cell newCell = row.createCell(colMax + icol);
194
					if (rowIndex == 0) {
195
						newCell.setCellValue(columnsToCopy.get(col)); // first column must be renamed
188
				for (String newcol : columnsToCopy.get(col)) {
189
					int colIndex = searchColumns.get(col);
190
					
191
					Cell cell = row.getCell(colIndex);
192
					if (cell != null) {
193
						
194
						Cell newCell = row.createCell(colMax + icol);
195
						if (rowIndex == 0) {
196
							newCell.setCellValue(newcol); // first column must be renamed
197
						}
198
						else {
199
							newCell.setCellValue(cellToString(cell).trim());
200
						}
196 201
					}
197
					else {
198
						newCell.setCellValue(cellToString(cell).trim());
199
					}
202
					icol++;
200 203
				}
201
				icol++;
202 204
			}
203 205
			
204 206
			nRowWritten++;
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/BuildAFMetadataMacro.groovy (revision 2943)
33 33
	table2File = new File(tableFile.getParentFile(), "emissions.xlsx");
34 34
	HashMap<String, String> lineRules = new HashMap<>(); // line tests to select line to keep
35 35
	List<String> columnsSelection; // list of columns to keep
36
	HashMap<String, String> columnsToCopy = new HashMap<>();
36
	HashMap<String, String[]> columnsToCopy = new HashMap<>();
37 37
	HashMap<String, String> columnsToRenameRules = new HashMap<>();
38 38
	HashMap<String, String[]> searchAndReplaceRules = new HashMap<>();
39 39
	
......
45 45
	
46 46
	columnsToRenameRules.put("Identifiant de la notice", "id");
47 47
	
48
	columnsToCopy.put("Notes du titre", "subtitle");
49
	columnsToCopy.put("Titre propre", "title"); 
50
	columnsToCopy.put("Date de diffusion", "textorder");
51
	columnsToCopy.put("Date de diffusion", "annee");
48
	columnsToCopy.put("Notes du titre", ["subtitle"] as String[]);
49
	columnsToCopy.put("Titre propre", ["title"] as String[]); 
50
	columnsToCopy.put("Date de diffusion", ["textorder", "annee"] as String[]);
52 51
	
53 52
	searchAndReplaceRules.put("textorder", ["([0-9][0-9])/([0-9][0-9])/([0-9][0-9][0-9][0-9])", '$3$2$1'] as String[]); // not working yet
54 53
	searchAndReplaceRules.put("annee", ["([0-9][0-9])/([0-9][0-9])/([0-9][0-9][0-9][0-9])", '$3'] as String[]); // not working yet
......
61 60
	table2File = new File(tableFile.getParentFile(), "sujets.xlsx");
62 61
	HashMap<String, String> lineRules = new HashMap<>(); // line tests to select line to keep
63 62
	List<String> columnsSelection; // list of columns to keep
64
	HashMap<String, String> columnsToCopy = new HashMap<>();
63
	HashMap<String, String[]> columnsToCopy = new HashMap<>();
65 64
	HashMap<String, String> columnsToRenameRules = new HashMap<>();
66 65
	HashMap<String, String[]> searchAndReplaceRules = new HashMap<>();
67 66
	

Formats disponibles : Unified diff