Created
August 31, 2014 07:41
-
-
Save nabinno/efb58f5023a49c434ef4 to your computer and use it in GitHub Desktop.
google apps script of deleting newline for google spreadsheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Retrieves all the rows in the active spreadsheet that contain data and logs the | |
* values for each row. | |
* For more information on using the Spreadsheet API, see | |
* https://developers.google.com/apps-script/service_spreadsheet | |
*/ | |
function deleteNewline() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var rows = sheet.getDataRange(); | |
var numRows = rows.getNumRows(); | |
var numColumns = rows.getNumColumns(); | |
var values = rows.getValues(); | |
for (var i = 0; i <= numRows - 1; i++) { | |
for (var j = 0; j <= numColumns - 1; j++) { | |
var row = values[i][j]; | |
var row2 = row.replace(/\n/g,""); | |
var cell = sheet.getRange(i+1,j+1); | |
cell.setValue(row2); | |
} | |
} | |
}; | |
/** | |
* Adds a custom menu to the active spreadsheet, containing a single menu item | |
* for invoking the readRows() function specified above. | |
* The onOpen() function, when defined, is automatically invoked whenever the | |
* spreadsheet is opened. | |
* For more information on using the Spreadsheet API, see | |
* https://developers.google.com/apps-script/service_spreadsheet | |
*/ | |
function onOpen() { | |
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var entries = [{ | |
name : "Delete Newline", | |
functionName : "deleteNewline" | |
}]; | |
spreadsheet.addMenu("Script Center Menu", entries); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment