My Excel file of CSV data from Google Apps Script doesn't mirror my Google Spreadsheet -
i'm trying write script passes information google spreadsheet, compiles csv file , emails file.
my problem: csv file on excel file looks different of google spreadsheet (dead link).
this excel file looks like, pasted google spreadsheet.
the code using below:
function myfunction() { //get active sheet, last row data has been entered, define range , use range values (called data) var sheet = spreadsheetapp.getactivesheet(); var lastrow=sheet.getlastrow(); var range = sheet.getrange(1,1,lastrow,91); var data = range.getvalues(); //define string called csv var csv = ""; //run loop through data , join values separated comma (var = 0; < data.length; ++i) { csv += data[i].join(",") + "\r\n"; } var csvfiles = [{filename:"example.csv", content:csv}]; mailapp.sendemail(session.getuser().getemail(), "new journey information", "", {attachments: csvfiles}); }
you need ensure individual cells' data atomic. instance, see time on sheet contains date object when read script, when that's written csv may converted date & time string commas, depending on locale. (jan 4, 2013 14:34 example.) safe punctuation may interpreted delimiters excel, should enclose each element quotes.
no need modify code, problem has been solved in 1 of examples provided in docslist tutorial. easy solution replace code.
change first bit of provided saveascsv()
follows, , operate either user input or passing filename parameter.
function saveascsv(filename) { // prompts user file name, if filename parameter not provided filename = filename || browser.inputbox("save csv file (e.g. mycsvfile):"); ...
Comments
Post a Comment