
Converter (Excel-CSV FILE to Table type data)
コンバータ (Excel-CSV ファイル to テーブル型データ)
This item overwrites the value of a Table type data item with a contents of an Excel compatible CSV file(TSV UTF-16 LE with BOM) stored in a File type data item.
Basic Configs
- Step Name
- Note
Configs for this Auto Step
- File_DataId
- A: File type data item that stores target Excel-CSV file *
- Table_DataId
- B: Table type data item to save Excel-CSV data *
Notes
- The input value of a CSV cell must be in the following format according to the data type of the corresponding table sub-item (column)
- String-type: (entered character string)
- Numeric-type: Standard format (period as decimal point, no thousands separator)
- Select-type: Choice ID
- Date-type: yyyy-mm-dd
Capture

See also
Script (click to open)
- An XML file that contains the code below is available to download
- converter-excelcsv-to-table.xml (C) Questetra, Inc. (MIT License)
- If you are using Professional, you can modify the contents of this file and use it as your own add-on auto step
function main() {
//// == 自動工程コンフィグの参照 / Config Retrieving ==
const myFilesDef = configs.getObject("File_DataId"); // (returns ProcessDataDefinitionView)
const tableDataDef = configs.getObject("Table_DataId"); // (returns ProcessDataDefinitionView)
const myFiles = engine.findData(myFilesDef);
// ファイル型データに複数添付されている場合、エラー
if (myFiles !== null && myFiles.size() > 1) {
throw new Error("Attachment of multiple files can not be supported.");
}
// テーブル型データ項目のために ListArray を作成する
const myTable = tableDataDef.createListArray();
// ファイル型データにファイルが1つ添付されている場合
if (myFiles !== null) {
// ファイル型を1行ずつ読み込んで、テーブル型にセット
fileRepository.readFile(myFiles.get(0), "x-UTF-16LE-BOM", function (line) {
// タブで列分割
const cellsArray = line.split("\t");
// ListArray に行を追加する
const newRow = myTable.addRow();
// テーブル型データ項目の値の行数
const numOfRows = myTable.size();
if (cellsArray.length !== newRow.size()) {
throw new Error(`Incorrect number of rows at line ${numOfRows}`);
}
// テーブル型データ項目の列数分繰り返す
for (let j = 0; j < newRow.size(); j++) {
newRow.setCol(j, cellsArray[j]);
}
});
}
//// == ワークフローデータへの代入 / Data Updating ==
// ファイル型データ項目にファイルが1つ添付されている場合はその値、1つも添付されていない場合は空をセット
engine.setData(tableDataDef, myTable);
}