ComposantsComponents › Fichier › SortieFile › Output
Écrit les lignes d'un flux dans une feuille d'un classeur Excel : une ligne de la feuille par ligne du flux, une cellule par colonne du schéma. Les nombres, les dates et les booléens deviennent des cellules de ce type. Le format par défaut est le .xls d'Excel 97-2003, écrit avec la bibliothèque jxl. Le format .xlsx demande une bibliothèque absente des dépôts publics : le job ne compile pas (voir plus bas).
Writes the rows of a flow to a sheet of an Excel workbook: one sheet row per flow row, one cell per schema column. Numbers, dates and booleans become cells of that type. The default format is the Excel 97-2003 .xls, written with the jxl library. The .xlsx format needs a library that is missing from public repositories: the job does not compile (see below).
Le schéma se remplit à partir du lien entrant. Cochez Inclure l'en-tête pour écrire le nom des colonnes sur la première ligne. The schema is filled from the incoming link. Check Include header to write the column names on the first row.
Même fichier, un autre Nom de la feuille, et Ajouter au fichier existant coché sur le second : la première feuille est gardée (exemple). Same file, another Sheet name, and Append existing file checked on the second one: the first sheet is kept (example).
.xls), le Nom de la feuille, et cochez au besoin Inclure l'en-tête.
Set the File Name (.xls), the Sheet name, and check Include header if needed.
Les libellés sont ceux de l'onglet Composant ; le nom technique, en gris, est celui du paramètre dans le fichier du job. Les réglages marqués « xlsx » n'ont pas pu être essayés : ils sont décrits d'après les modèles du composant. Labels are those of the Component tab; the technical name, in grey, is the parameter name in the job file. The settings marked “xlsx” could not be tried: they are described from the component templates.
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| Type de propriétéProperty TypePROPERTY | Built-in | ToujoursAlways | Built-in : les réglages sont saisis ici. Référentiel : le nom du fichier, l'encodage et les séparateurs avancés viennent d'une métadonnée de fichier Excel du référentiel. Built-in: the settings are typed here. Repository: the file name, the encoding and the advanced separators come from an Excel file metadata of the Repository. |
| Écrire au format de fichier Excel 2007 (xlsx)Write excel2007 file format (xlsx)VERSION_2007 | NonNo | ToujoursAlways |
Décochée : fichier .xls (Excel 97-2003), écrit avec jxl 2.6.12. Cochée : fichier .xlsx, écrit avec la bibliothèque talendExcel, introuvable : le job ne compile pas (voir xlsx).
Unchecked: .xls file (Excel 97-2003), written with jxl 2.6.12. Checked: .xlsx file, written with the talendExcel library, which cannot be found: the job does not compile (see xlsx).
|
| Utiliser le flux de sortieUse Output StreamUSESTREAM | NonNo | ToujoursAlways |
Écrit le classeur dans un flux Java (java.io.OutputStream) au lieu d'un fichier. Nom de fichier, Ajouter au fichier existant, Créer le répertoire s'il n'existe pas et Ne pas générer de fichier vide sont alors masqués (exemple).
Writes the workbook to a Java stream (java.io.OutputStream) instead of a file. File Name, Append existing file, Create directory if does not exist and Don't generate empty file are then hidden (example).
|
| Flux de sortieOutput StreamSTREAMNAME | outputStream |
Flux de sortie cochéOutput Stream checked |
Expression Java qui donne le flux : (java.io.OutputStream) globalMap.get("out"). D'après le modèle, le composant ne le ferme pas en xls : fermez-le ensuite.
Java expression that gives the stream: (java.io.OutputStream) globalMap.get("out"). From the template, the component does not close it in xls: close it afterwards.
|
| Nom de fichierFile NameFILENAME | chemin par défaut + /out.xlsdefault path + /out.xls |
Flux de sortie décochéOutput Stream unchecked |
Le classeur écrit, en expression Java : context.folder + "/customers.xls". Sans Ajouter au fichier existant, il est remplacé. Le fichier est vidé dès le début : une erreur pendant l'écriture le laisse vide (voir les erreurs).
The written workbook, as a Java expression: context.folder + "/customers.xls". Without Append existing file, it is replaced. The file is emptied at the start: an error while writing leaves it empty (see the errors).
|
| Nom de la feuilleSheet nameSHEETNAME | "Sheet1" |
ToujoursAlways | La feuille écrite, en expression Java. Elle est créée si le classeur ne l'a pas. The written sheet, as a Java expression. It is created if the workbook does not have it. |
| Inclure l'en-têteInclude headerINCLUDEHEADER | NonNo | ToujoursAlways | Écrit le nom des colonnes du schéma sur la première ligne. Il n'est pas répété quand les lignes s'ajoutent à une feuille qui en a déjà. Writes the schema column names on the first row. It is not repeated when the rows are added to a sheet that already has some. |
| Ajouter au fichier existantAppend existing fileAPPEND_FILE | NonNo | Flux de sortie décochéOutput Stream unchecked | Garde le classeur existant et ses autres feuilles. Sans Ajouter à la feuille existante, une feuille du même nom est supprimée puis recréée, en dernière position (exemples). Keeps the existing workbook and its other sheets. Without Append existing sheet, a sheet with the same name is deleted then created again, in last position (examples). |
| Ajouter à la feuille existanteAppend existing sheetAPPEND_SHEET | NonNo | Ajouter au fichier coché, sans fluxAppend file checked, no stream | Écrit les lignes après la dernière ligne de la feuille. Writes the rows after the last row of the sheet. |
| Est absolument une position YIs absolute Y pos.FIRST_CELL_Y_ABSOLUTE | NonNo | Sauf Écrire à la suite en mode flux cochéExcept Streaming append checked | Écrit à partir d'une cellule fixe, donnée par Première cellule X et Y, au lieu de la première ligne libre (exemple). D'après le modèle, cette position vaut aussi en ajout à une feuille existante : les cellules déjà là sont remplacées. Writes from a fixed cell, given by First cell X and Y, instead of the first free row (example). From the template, this position also applies when appending to an existing sheet: the cells already there are replaced. |
| Première cellule XFirst cell XFIRST_CELL_X | 0 |
Position Y absolue cochéeAbsolute Y pos. checked |
Colonne de la première cellule, comptée à partir de 0 : 2 pour la colonne C.
Column of the first cell, counted from 0: 2 for column C.
|
| Première cellule YFirst cell YFIRST_CELL_Y | 0 |
Position Y absolue cochéeAbsolute Y pos. checked |
Ligne de la première cellule, comptée à partir de 0 : 3 pour la ligne 4. L'en-tête, s'il est demandé, y est écrit.
Row of the first cell, counted from 0: 3 for row 4. The header, if asked for, is written there.
|
| Conserver le format de cellule existantKeep existing cell formatKEEP_CELL_FORMATING | NonNo | Position Y absolue cochéeAbsolute Y pos. checked | D'après le modèle (non essayé) : en xls, chaque cellule écrite reprend le format de la cellule qui était à sa place dans la feuille. Sert à remplir un classeur modèle, avec Ajouter au fichier existant et Ajouter à la feuille existante. From the template (not tried): in xls, each written cell takes the format of the cell that was at its place in the sheet. Used to fill a template workbook, with Append existing file and Append existing sheet. |
| PoliceFontFONT | Par défautDefault | ToujoursAlways | Arial, Times New Roman, Courier New ou Tahoma, en taille 10, pour toutes les cellules écrites, en-tête compris. Par défaut : Arial 10 dans nos essais (xls). Voir l'exemple. Arial, Times New Roman, Courier New or Tahoma, in size 10, for all the written cells, header included. Default: Arial 10 in our tests (xls). See the example. |
| Définir une taille auto pour toutes les colonnesDefine all columns auto sizeIS_ALL_AUTO_SZIE | NonNo | ToujoursAlways | Élargit chaque colonne. En xls, une colonne prend la longueur de sa plus longue valeur plus 2 caractères, jamais moins que la largeur par défaut (8). Une colonne de dates prend la longueur de son modèle, guillemets compris, plus 2 (exemple). Widens each column. In xls, a column takes the length of its longest value plus 2 characters, never less than the default width (8). A date column takes the length of its pattern, quotes included, plus 2 (example). |
| Définir taille auto de la colonneDefine column auto sizeAUTO_SZIE_SETTING | tout décochéall unchecked | Taille auto pour toutes décochéeAll columns auto size unchecked | Une ligne par colonne du schéma, avec une case Taille automatique : seules les colonnes cochées sont élargies. One line per schema column, with an Auto size box: only the checked columns are widened. |
| Protéger le fichierProtect filePROTECT_FILE | NonNo | xlsx, sans fluxxlsx, no stream |
xlsx : passe le Mot de passe à la bibliothèque (setPasswordProtection). Non essayé.
xlsx: passes the Password to the library (setPasswordProtection). Not tried.
|
| Mot de passePasswordPASSWORD | "" |
Protéger le fichier cochéProtect file checked | Le mot de passe de protection du classeur xlsx. The protection password of the xlsx workbook. |
| SchémaSchemaSCHEMA | — | ToujoursAlways | Les colonnes écrites, dans leur ordre : une cellule par colonne. Le type de la colonne donne le type de la cellule (voir conseils). Une colonne Date doit avoir un modèle de date. The written columns, in their order: one cell per column. The column type gives the cell type (see tips). A Date column must have a date pattern. |
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| Créer le répertoire s'il n'existe pasCreate directory if does not existCREATE | OuiYes | Flux de sortie décochéOutput Stream unchecked | Crée le dossier du fichier, avec ses parents. Décochée, un dossier absent arrête le job (voir les erreurs). Creates the folder of the file, with its parents. Unchecked, a missing folder stops the job (see the errors). |
| Personnaliser la taille de la mémoire tamponCustom the flush buffer sizeFLUSHONROW | NonNo | xlsx, sans ajout au fichier (ou avec flux)xlsx, no file append (or with stream) | xlsx : d'après le modèle, coupe le vidage automatique de la bibliothèque et vide les lignes en mémoire toutes les Nombre de lignes lignes. Non essayé. xlsx: from the template, turns off the automatic flush of the library and flushes the rows in memory every Row number rows. Not tried. |
| Nombre de lignesRow numberFLUSHONROW_NUM | 100 |
Taille de la mémoire tampon cochéeFlush buffer size checked | Nombre de lignes entre deux vidages, en expression Java entière. Number of rows between two flushes, as an integer Java expression. |
| Séparateur avancé (pour les nombres)Advanced separator (for numbers)ADVANCED_SEPARATOR | NonNo | ToujoursAlways | Écrit les nombres comme du texte, mis en forme avec les deux séparateurs : Excel ne les voit plus comme des nombres. Toutes les colonnes numériques sont concernées, entiers compris (exemple). Writes numbers as text, formatted with the two separators: Excel no longer sees them as numbers. All numeric columns are concerned, integers included (example). |
| Séparateur de milliersThousands separatorTHOUSANDS_SEPARATOR | "," |
Séparateur avancé cochéAdvanced separator checked | Caractère placé entre les milliers. Character placed between the thousands. |
| Séparateur décimalDecimal separatorDECIMAL_SEPARATOR | "." |
Séparateur avancé cochéAdvanced separator checked | Caractère placé avant les décimales. Un BigDecimal est d'abord arrondi à la précision de sa colonne. Character placed before the decimals. A BigDecimal is first rounded to the precision of its column. |
| Tronquer les caractères dépassant la longueur maximale de la celluleTruncate characters exceeding max cell lengthTRUNCATE_EXCEEDING_CHARACTERS | NonNo | xlsx |
xlsx : passé à la bibliothèque (setTruncateExceedingCharacters) ; d'après son libellé, coupe les textes trop longs pour une cellule. Non essayé.
xlsx: passed to the library (setTruncateExceedingCharacters); from its label, cuts the texts too long for a cell. Not tried.
|
| EncodageEncodingENCODING | "ISO-8859-15" |
ToujoursAlways |
xls : passé tel quel aux réglages du classeur jxl (WorkbookSettings.setEncoding). Le modèle xlsx ne s'en sert pas.
xls: passed as is to the jxl workbook settings (WorkbookSettings.setEncoding). The xlsx template does not use it.
|
| Ne pas générer de fichier videDon't generate empty fileDELETE_EMPTYFILE | NonNo | Flux de sortie décochéOutput Stream unchecked | Supprime le fichier à la fin s'il n'a reçu aucune ligne, même avec l'en-tête (exemple). D'après le modèle, un fichier qui existait déjà, en ajout au fichier existant, est gardé. Deletes the file at the end if it received no row, even with the header (example). From the template, a file that already existed, when appending to the file, is kept. |
| Recalculer la formuleRecalculate formulaRECALCULATE_FORMULA | NonNo | xlsx, ajout au fichier et à la feuille, sans mode fluxxlsx, file and sheet append, no streaming |
xlsx : passé à la bibliothèque (setRecalculateFormula) ; d'après son libellé, recalcule les formules du classeur. Non essayé.
xlsx: passed to the library (setRecalculateFormula); from its label, recalculates the workbook formulas. Not tried.
|
| Écrire à la suite en mode fluxStreaming appendSTREAMING_APPEND | NonNo | xlsx, ajout au fichier cochéxlsx, file append checked | xlsx : ajout en mode flux. Demande en plus la bibliothèque xlsx-streamer 2.1.0-20201125, elle aussi absente des dépôts publics. Non essayé. xlsx: streaming append. Also needs the xlsx-streamer 2.1.0-20201125 library, which is missing from public repositories too. Not tried. |
| Utiliser la table des chaînes de caractères partagéesUse shared strings tableUSE_SHARED_STRINGS_TABLE | NonNo | xlsx, sans ajout au fichierxlsx, no file append |
xlsx : passé à la bibliothèque (setUseSharedStringTable). Non essayé.
xlsx: passed to the library (setUseSharedStringTable). Not tried.
|
NB_LINE (Integer, disponible après l'exécution du composant) : nombre de lignes écrites, sans l'en-tête. Dans les exemples : 3 pour trois lignes et l'en-tête, 1 pour une ligne ajoutée à une feuille, 0 sans ligne. NB_LINE (Integer, available after the component has run): number of rows written, without the header. In the examples: 3 for three rows and the header, 1 for one row added to a sheet, 0 without rows.
System.out.println("NB_LINE: " + globalMap.get("tFileOutputExcel_1_NB_LINE"));
Un tFixedFlowInput envoie les lignes ci-dessous au tFileOutputExcel, en xls. Les chemins sont écrits à partir de la variable de contexte folder. Un tJava relié par On Subjob Ok relit ensuite le classeur avec jxl, déjà dans le classpath du job, et affiche chaque cellule non vide avec sa référence. Les sorties sont celles de la console, copiées depuis une exécution du job.
A tFixedFlowInput sends the rows below to the tFileOutputExcel, in xls. Paths are written from the folder context variable. A tJava connected with On Subjob Ok then reads the workbook back with jxl, already on the job classpath, and prints each non-empty cell with its reference. The outputs are the console ones, copied from a run of the job.
| idInteger | nameString | amountBigDecimal, précisionprecision 2 | sinceDate, "dd-MM-yyyy" |
activeBoolean |
|---|---|---|---|---|
| 1 | Ada | 1250.5 | 2021-03-15 | true |
| 2 | Grace | null | 2023-11-02 | false |
| 3 | Alan | 3.14159 | null | true |
| 4 | Margaret | 99 | 2024-06-30 | false |
La ligne 4 sert dans les exemples d'ajout. Row 4 is used in the append examples.
jxl.Workbook wb = jxl.Workbook.getWorkbook(
new java.io.File(context.folder + "/xls/customers.xls"));
for (jxl.Sheet s : wb.getSheets()) {
System.out.println("Sheet " + s.getName() + ": " + s.getRows()
+ " rows, " + s.getColumns() + " columns");
for (int r = 0; r < s.getRows(); r++) {
StringBuilder sb = new StringBuilder();
for (jxl.Cell c : s.getRow(r)) {
if (c.getType() == jxl.CellType.EMPTY) continue;
if (sb.length() > 0) sb.append(" | ");
sb.append(jxl.CellReferenceHelper.getCellReference(
c.getColumn(), c.getRow())).append(" ").append(c.getContents());
sb.append(" (").append(c.getType()).append(")"); // first example only
}
if (sb.length() > 0) System.out.println(sb);
}
}
wb.close();
Lignes 1 à 3, Nom de la feuille "Customers", Inclure l'en-tête coché. La relecture affiche aussi le type de chaque cellule, puis NB_LINE.
Rows 1 to 3, Sheet name "Customers", Include header checked. The reading also prints the type of each cell, then NB_LINE.
Sheet Customers: 4 rows, 5 columns A1 id (Label) | B1 name (Label) | C1 amount (Label) | D1 since (Label) | E1 active (Label) A2 1 (Number) | B2 Ada (Label) | C2 1250,5 (Number) | D2 15-03-2021 (Date) | E2 true (Boolean) A3 2 (Number) | B3 Grace (Label) | D3 02-11-2023 (Date) | E3 false (Boolean) A4 3 (Number) | B4 Alan (Label) | C4 3,14 (Number) | E4 true (Boolean) NB_LINE: 3
Une valeur nulle ne crée pas de cellule : C3 et D4 sont absentes. Les nombres sont des cellules Number (le montant est arrondi à sa précision : 3,14), les dates des cellules Date au format de la colonne, le texte des cellules Label. jxl affiche les nombres avec le séparateur décimal de la machine, une virgule ici (Windows en français) : la cellule C2 contient bien le nombre 1250.5. NB_LINE ne compte pas l'en-tête. A null value creates no cell: C3 and D4 are missing. Numbers are Number cells (the amount is rounded to its precision: 3,14), dates are Date cells in the column format, text is Label cells. jxl prints numbers with the decimal separator of the machine, a comma here (French Windows): cell C2 does hold the number 1250.5. NB_LINE does not count the header.
Mêmes lignes, seul le Nom de fichier est changé : Same rows, only the File Name is changed:
Sheet Sheet1: 3 rows, 5 columns A1 1 | B1 Ada | C1 1250,5 | D1 15-03-2021 | E1 true A2 2 | B2 Grace | D2 02-11-2023 | E2 false A3 3 | B3 Alan | C3 3,14 | E3 true NB_LINE: 3
Feuille Sheet1, sans en-tête : les données commencent en A1.
Sheet Sheet1, no header: the data starts at A1.
Lignes 1 et 2, en-tête, Est absolument une position Y coché, Première cellule X 2, Y 3 :
Rows 1 and 2, header, Is absolute Y pos. checked, First cell X 2, Y 3:
Sheet Sheet1: 6 rows, 7 columns C4 id | D4 name | E4 amount | F4 since | G4 active C5 1 | D5 Ada | E5 1250,5 | F5 15-03-2021 | G5 true C6 2 | D6 Grace | F6 02-11-2023 | G6 false NB_LINE: 2
X et Y comptent à partir de 0 : l'en-tête commence en C4, les colonnes A et B et les lignes 1 à 3 restent vides. X and Y count from 0: the header starts at C4, columns A and B and rows 1 to 3 stay empty.
Un seul job, quatre sous-jobs reliés par On Subjob Ok, tous sur append.xls, en-tête coché. Le premier écrit les lignes 1 à 3 dans la feuille Customers. Les trois suivants ont Ajouter au fichier existant coché et écrivent la ligne 4 ; un tJava relit le classeur après chacun.
One job, four subjobs connected with On Subjob Ok, all on append.xls, header checked. The first one writes rows 1 to 3 in the Customers sheet. The next three have Append existing file checked and write row 4; a tJava reads the workbook back after each one.
Feuille "Archive" : elle s'ajoute, Customers est gardée.
Sheet "Archive": it is added, Customers is kept.
Sheet Customers: 4 rows, 5 columns A1 id | B1 name | C1 amount | D1 since | E1 active A2 1 | B2 Ada | C2 1250,5 | D2 15-03-2021 | E2 true A3 2 | B3 Grace | D3 02-11-2023 | E3 false A4 3 | B4 Alan | C4 3,14 | E4 true Sheet Archive: 2 rows, 5 columns A1 id | B1 name | C1 amount | D1 since | E1 active A2 4 | B2 Margaret | C2 99 | D2 30-06-2024 | E2 false
Feuille "Customers", Ajouter à la feuille existante coché : la ligne arrive en A5, l'en-tête n'est pas répété.
Sheet "Customers", Append existing sheet checked: the row arrives at A5, the header is not repeated.
Sheet Customers: 5 rows, 5 columns A1 id | B1 name | C1 amount | D1 since | E1 active A2 1 | B2 Ada | C2 1250,5 | D2 15-03-2021 | E2 true A3 2 | B3 Grace | D3 02-11-2023 | E3 false A4 3 | B4 Alan | C4 3,14 | E4 true A5 4 | B5 Margaret | C5 99 | D5 30-06-2024 | E5 false Sheet Archive: 2 rows, 5 columns A1 id | B1 name | C1 amount | D1 since | E1 active A2 4 | B2 Margaret | C2 99 | D2 30-06-2024 | E2 false NB_LINE: 1
Feuille "Customers", Ajouter à la feuille existante décoché :
Sheet "Customers", Append existing sheet unchecked:
Sheet Archive: 2 rows, 5 columns A1 id | B1 name | C1 amount | D1 since | E1 active A2 4 | B2 Margaret | C2 99 | D2 30-06-2024 | E2 false Sheet Customers: 2 rows, 5 columns A1 id | B1 name | C1 amount | D1 since | E1 active A2 4 | B2 Margaret | C2 99 | D2 30-06-2024 | E2 false
L'ancienne feuille Customers est supprimée et une nouvelle est créée, après Archive : l'ordre des feuilles change.
The old Customers sheet is deleted and a new one is created, after Archive: the sheet order changes.
Lignes 1 à 4, en-tête, trois fichiers : réglages par défaut, Définir une taille auto pour toutes les colonnes coché, Police Courier New. Le tJava affiche la largeur de chaque colonne (getColumnView(c).getSize(), en 256es de caractère) et la police de A1 et A2 :
Rows 1 to 4, header, three files: default settings, Define all columns auto size checked, Font Courier New. The tJava prints the width of each column (getColumnView(c).getSize(), in 256ths of a character) and the font of A1 and A2:
default: widths 2048/256 2048/256 2048/256 2048/256 2048/256, font A1 Arial 10, font A2 Arial 10 auto size: widths 2048/256 2560/256 2048/256 3584/256 2048/256, font A1 Arial 10, font A2 Arial 10 Courier: widths 2048/256 2048/256 2048/256 2048/256 2048/256, font A1 Courier New 10, font A2 Courier New 10
Par défaut, chaque colonne a 8 caractères de large. En taille auto, name passe à 10 (Margaret, 8 lettres, plus 2) et since à 14 ("dd-MM-yyyy", 12 caractères avec les guillemets, plus 2) ; les autres restent à 8. La police s'applique à l'en-tête comme aux données.
By default, each column is 8 characters wide. With auto size, name goes to 10 (Margaret, 8 letters, plus 2) and since to 14 ("dd-MM-yyyy", 12 characters with the quotes, plus 2); the others stay at 8. The font applies to the header as well as to the data.
Lignes 1 et 3, en-tête, Séparateur avancé coché, milliers ".", décimales "," :
Rows 1 and 3, header, Advanced separator checked, thousands ".", decimals ",":
Sheet Sheet1: 3 rows, 5 columns A1 id (Label) | B1 name (Label) | C1 amount (Label) | D1 since (Label) | E1 active (Label) A2 1 (Label) | B2 Ada (Label) | C2 1.250,50 (Label) | D2 15-03-2021 (Date) | E2 true (Boolean) A3 3 (Label) | B3 Alan (Label) | C3 3,14 (Label) | E3 true (Boolean)
Le montant et l'identifiant sont devenus du texte (Label) : Excel ne peut plus les additionner. The amount and the id became text (Label): Excel can no longer add them up.
Le tFixedFlowInput n'envoie aucune ligne. Deux fichiers, en-tête coché : Ne pas générer de fichier vide coché pour le premier, décoché pour le second. The tFixedFlowInput sends no row. Two files, header checked: Don't generate empty file checked for the first one, unchecked for the second one.
empty_deleted.xls exists: false, NB_LINE: 0 empty_kept.xls exists: true, NB_LINE: 0 Sheet Sheet1: 1 rows, 5 columns A1 id | B1 name | C1 amount | D1 since | E1 active
L'en-tête seul ne compte pas comme une ligne : le premier fichier est supprimé, le second ne contient que l'en-tête. The header alone does not count as a row: the first file is deleted, the second one only holds the header.
Le tJava_1 ouvre le flux : globalMap.put("out", new java.io.FileOutputStream(context.folder + "/xls/stream.xls"));. Utiliser le flux de sortie coché, Flux de sortie (java.io.OutputStream) globalMap.get("out"), lignes 1 et 2, en-tête. Le tJava_2 ferme le flux, affiche la taille du fichier, puis le relit :
tJava_1 opens the stream: globalMap.put("out", new java.io.FileOutputStream(context.folder + "/xls/stream.xls"));. Use Output Stream checked, Output Stream (java.io.OutputStream) globalMap.get("out"), rows 1 and 2, header. tJava_2 closes the stream, prints the file size, then reads it back:
stream.xls: 13824 bytes, unused.xls exists: false Sheet Sheet1: 3 rows, 5 columns A1 id | B1 name | C1 amount | D1 since | E1 active A2 1 | B2 Ada | C2 1250,5 | D2 15-03-2021 | E2 true A3 2 | B3 Grace | D3 02-11-2023 | E3 false
Le Nom de fichier resté dans le composant (unused.xls) n'est pas créé.
The File Name left in the component (unused.xls) is not created.
Avec Écrire au format de fichier Excel 2007 (xlsx) coché, le code généré écrit le classeur avec la classe org.talend.ExcelTool de la bibliothèque mvn:org.talend.components/talendExcel/1.15-20230117. Cette version n'est ni sur Maven Central ni sur le dépôt Nexus de Talaxie. Les autres bibliothèques du format xlsx (Apache POI et ses dépendances) ont été trouvées ; Écrire à la suite en mode flux demanderait en plus mvn:com.monitorjbl/xlsx-streamer/2.1.0-20201125, absente elle aussi.
With Write excel2007 file format (xlsx) checked, the generated code writes the workbook with the org.talend.ExcelTool class of the mvn:org.talend.components/talendExcel/1.15-20230117 library. This version is neither on Maven Central nor on the Talaxie Nexus repository. The other libraries of the xlsx format (Apache POI and its dependencies) were found; Streaming append would also need mvn:com.monitorjbl/xlsx-streamer/2.1.0-20201125, which is missing too.
Le job des exemples, en xlsx, lancé avec Talaxie : la bibliothèque est introuvable, puis la compilation échoue. Le nom du job est remplacé par MyJob, le chemin du code est abrégé.
The job of the examples, in xlsx, run with Talaxie: the library is not found, then the compilation fails. The job name is replaced with MyJob, the code path is shortened.
Library not found: mvn:org.talend.components/talendExcel/1.15-20230117 The job failed to compile: …\src\doci\myjob_0_1\MyJob.java:970: error: cannot find symbol org.talend.ExcelTool xlsxTool_tFileOutputExcel_1 = new org.talend.ExcelTool(); ^ symbol: class ExcelTool location: package org.talend … 2 errors
Les réglages propres au xlsx sont donc décrits d'après les modèles du composant, sans essai. Pour un fichier lisible par Excel aujourd'hui, gardez le format xls, ou écrivez un CSV avec tFileOutputDelimited. The xlsx-only settings are therefore described from the component templates, without trying them. For a file Excel can read today, keep the xls format, or write a CSV with tFileOutputDelimited.
Le nom du job est remplacé par MyJob, le dossier de travail par C:\data ; les traces d'exception sont abrégées. Sans lien On Subjob Error, le job s'arrête avec le code de sortie 1 ; dans le deuxième cas, qui a ce lien, il finit avec le code 0. La fin des messages de fichier vient de Windows, dans sa langue.
The job name is replaced with MyJob, the working folder with C:\data; exception traces are shortened. Without an On Subjob Error link, the job stops with exit code 1; in the second case, which has this link, it ends with exit code 0. The end of the file messages comes from Windows, in its language.
La colonne since n'a pas de modèle de date dans le schéma :
The since column has no date pattern in the schema:
Exception in component tFileOutputExcel_1 (MyJob) java.lang.RuntimeException: Date pattern must be set for column since in the schema of component tFileOutputExcel_1! at doci.myjob_0_1.MyJob.tFixedFlowInput_1Process(MyJob.java:994) …
L'erreur arrive avant la première ligne, mais après l'ouverture du fichier : il reste vide (0 octet). Donnez un modèle, par exemple "dd-MM-yyyy", dans Modifier le schéma.
The error comes before the first row, but after the file is opened: it stays empty (0 bytes). Give a pattern, for example "dd-MM-yyyy", in Edit schema.
Un premier sous-job écrit append_fail.xls ; le second l'ouvre avec Ajouter au fichier existant, mais sa colonne since n'a pas de modèle. Un tJava affiche la taille du fichier avant, puis après par On Subjob Error :
A first subjob writes append_fail.xls; the second one opens it with Append existing file, but its since column has no pattern. A tJava prints the file size before, then after with On Subjob Error:
before: 13824 bytes Exception in component tFileOutputExcel_2 (MyJob) java.lang.RuntimeException: Date pattern must be set for column since in the schema of component tFileOutputExcel_2! … after: 0 bytes
En ajout, le classeur est lu en mémoire, puis le fichier est aussitôt rouvert, donc vidé, et réécrit en entier à la fin. Une erreur entre les deux le laisse vide : toutes ses feuilles sont perdues. Gardez une copie du classeur (tFileCopy) avant de l'enrichir. When appending, the workbook is read into memory, then the file is opened again at once, so emptied, and fully rewritten at the end. An error in between leaves it empty: all its sheets are lost. Keep a copy of the workbook (tFileCopy) before adding to it.
Fichier context.folder + "/xls/missing/out.xls", dossier missing absent, Créer le répertoire s'il n'existe pas décoché :
File context.folder + "/xls/missing/out.xls", missing folder absent, Create directory if does not exist unchecked:
Exception in component tFileOutputExcel_1 (MyJob) java.io.FileNotFoundException: C:\data\xls\missing\out.xls (Le chemin d’accès spécifié est introuvable) at java.base/java.io.FileOutputStream.open0(Native Method) …
En-tête et 65 536 lignes de données, soit 65 537 lignes : Header and 65,536 data rows, so 65,537 rows:
Exception in component tFileOutputExcel_1 (MyJob) jxl.write.biff.RowsExceededException: The maximum number of rows permitted on a worksheet been exceeded at jxl.write.biff.WritableSheetImpl.getRowRecord(WritableSheetImpl.java:1214) at jxl.write.biff.WritableSheetImpl.addCell(WritableSheetImpl.java:1151) …
Avec l'en-tête et 65 535 lignes (65 536 en tout), le job passe (NB_LINE : 65535). Le fichier en erreur reste vide (0 octet). With the header and 65,535 rows (65,536 in all), the job succeeds (NB_LINE: 65535). The file in error stays empty (0 bytes).
D'après le modèle xls, vérifié sur les types des exemples : Integer, Long, Short, Byte, Float, Double et BigDecimal donnent un nombre ; String, Character, byte[], Object et List du texte ; Date une date au modèle de la colonne ; Boolean un booléen. Une valeur nulle ne crée pas de cellule. Avec Séparateur avancé, tous les nombres deviennent du texte. From the xls template, checked on the types of the examples: Integer, Long, Short, Byte, Float, Double and BigDecimal give a number; String, Character, byte[], Object and List give text; Date a date in the column pattern; Boolean a boolean. A null value creates no cell. With Advanced separator, all numbers become text.
En xls, le fichier est ouvert (donc vidé) au démarrage du composant, le classeur est construit en mémoire, puis écrit quand toutes les lignes sont passées. Un gros volume occupe la mémoire du job, et une erreur en cours de route laisse un fichier vide. In xls, the file is opened (so emptied) when the component starts, the workbook is built in memory, then written once all the rows have gone through. A large volume uses the job memory, and an error along the way leaves an empty file.
Une feuille xls a au plus 65 536 lignes, en-tête compris. Au-delà, répartissez les lignes sur plusieurs feuilles (un tFileOutputExcel par feuille, avec Ajouter au fichier existant), ou écrivez un CSV. An xls sheet has at most 65,536 rows, header included. Beyond that, spread the rows over several sheets (one tFileOutputExcel per sheet, with Append existing file), or write a CSV.
Pour vérifier un fichier écrit, relisez-le avec tFileInputExcel, ou dans un tJava avec les classes jxl, comme dans les exemples : la bibliothèque est déjà dans le classpath du job.
To check a written file, read it back with tFileInputExcel, or in a tJava with the jxl classes, as in the examples: the library is already on the job classpath.
tFileOutputDelimited · écrire un fichier CSV, qu'Excel ouvre aussiwrite a CSV file, which Excel opens tootFileCopy · copier le classeur avant de l'enrichircopy the workbook before adding to ittFileExist · tester si le classeur existe déjàtest whether the workbook already existstFileDelete · supprimer un ancien classeurdelete an old workbooktFileArchive · compresser les classeurs écritscompress the written workbookstRowGenerator · produire des lignes d'essaiproduce test rowstFileOutputProperties · écrire un fichier .properties ou .iniwrite a .properties or .ini filetLogRow · afficher les lignes avant de les écriredisplay the rows before writing them