"google sheets script save A RANGE to csv" Code Answer's
You're definitely familiar with the best coding language TypeScript that developers use to develop their projects and they get all their queries like "google sheets script save A RANGE to csv" answered properly. Developers are finding an appropriate answer about google sheets script save A RANGE to csv related to the TypeScript coding language. By visiting this online portal developers get answers concerning TypeScript codes question like google sheets script save A RANGE to csv. Enter your desired code related query in the search bar and get every piece of information about TypeScript code related question on google sheets script save A RANGE to csv.
google sheets script save A RANGE to csv
function saveAsCSV() {
// Prompts the user for the file name
var fileName = Browser.inputBox("Save CSV file as (e.g. myCSVFile):");
// Check that the file name entered wasn't empty
if (fileName.length !== 0) {
// Add the ".csv" extension to the file name
fileName = fileName + ".csv";
// Convert the range data to CSV format
var csvFile = convertRangeToCsvFile_(fileName);
// Create a file in Drive with the given name, the CSV data and MimeType (file type)
DriveApp.createFile(fileName, csvFile, MimeType.CSV);
}
else {
Browser.msgBox("Error: Please enter a CSV file name.");
}
}
function convertRangeToCsvFile_(csvFileName) {
// Get the selected range in the spreadsheet
var ws = SpreadsheetApp.getActiveSpreadsheet().getActiveSelection();
try {
var data = ws.getValues();
var csvFile = undefined;
// Loop through the data in the range and build a string with the CSV data
if (data.length > 1) {
var csv = "";
for (var row = 0; row < data.length; row++) {
for (var col = 0; col < data[row].length; col++) {
if (data[row][col].toString().indexOf(",") != -1) {
data[row][col] = "\"" + data[row][col] + "\"";
}
}
// Join each row's columns
// Add a carriage return to end of each row, except for the last one
if (row < data.length-1) {
csv += data[row].join(",") + "\r\n";
}
else {
csv += data[row];
}
}
csvFile = csv;
}
return csvFile;
}
catch(err) {
Logger.log(err);
Browser.msgBox(err);
}
}
Source: hawksey.info
google sheets script save A RANGE to csv
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var searchMenuEntries = [ {name: "Search in all files", functionName: "search"}];
var csvMenuEntries = [{name: "Save as CSV file", functionName: "saveAsCSV"},
{name: "Load from CSV file", functionName: "importFromCSV"}];
ss.addMenu("Search Google Drive", searchMenuEntries);
ss.addMenu("CSV", csvMenuEntries);
}
Source: hawksey.info
All those coders who are working on the TypeScript based application and are stuck on google sheets script save A RANGE to csv can get a collection of related answers to their query. Programmers need to enter their query on google sheets script save A RANGE to csv related to TypeScript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about google sheets script save A RANGE to csv for the programmers working on TypeScript code while coding their module. Coders are also allowed to rectify already present answers of google sheets script save A RANGE to csv while working on the TypeScript language code. Developers can add up suggestions if they deem fit any other answer relating to "google sheets script save A RANGE to csv". Visit this developer's friendly online web community, CodeProZone, and get your queries like google sheets script save A RANGE to csv resolved professionally and stay updated to the latest TypeScript updates.