I am using Google scripts to try and output 2 .txt files by reading in the information from Sheet 1.
I want my files to look like below one for just titles and the other for footnotes:
Therefore the '|' character in the footnote column needs to split onto a new line with the same program name listed as above.
The attached sheet is a basic example, but I need guidance which would also work if the footnote column had multiple '|'characters.
Any help is appreciated.
Use the split()
JS String method to obtain your strings in a single array.
When obtaining the values from a Spreadsheet the Apps Script methods will arrange them in multidimensional Arrays using this fashon: sheet[rows][columns]
.
In this example I will use the 3rd column, but you can of course adapt this method to whatever column serves you best:
function splitter() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var thirdColumnValues = ss.getDataRange().getValues().flatMap(row => row[2].split('|'));
var text = thirdColumnValues.join("\n"); //Just concatenate the values with the "return" symbol
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.