Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script Google应用程序脚本导出CSV日期格式问题_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script Google应用程序脚本导出CSV日期格式问题

Google apps script Google应用程序脚本导出CSV日期格式问题,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我有一个问题,我正试图解决与导出的日期格式。我的Google工作表的日期格式为MM/DD/YYYY,CSV文件的日期格式为{Thu Aug 27 2020 00:00:00 GMT-0400(东部夏时制)} 查看是否有方法使用日期格式或MM/DD/YYY获取此CSV下载代码 代码剪报+++++++++++++++++++ function convertRangeToCsvFile_(csvFileName, sheet) { // get available data range in t

我有一个问题,我正试图解决与导出的日期格式。我的Google工作表的日期格式为MM/DD/YYYY,CSV文件的日期格式为{Thu Aug 27 2020 00:00:00 GMT-0400(东部夏时制)}

查看是否有方法使用日期格式或MM/DD/YYY获取此CSV下载代码

代码剪报+++++++++++++++++++

function convertRangeToCsvFile_(csvFileName, sheet) {
  // get available data range in the spreadsheet
  var activeRange = sheet.getDataRange();
  try {
    var data = activeRange.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);
  }
}
函数convertRangeToCsvFile_932;(csvFileName,工作表){
//获取电子表格中的可用数据范围
var activeRange=sheet.getDataRange();
试一试{
var data=activeRange.getValues();
var csvFile=未定义;
//循环遍历范围中的数据,并使用csv数据构建字符串
如果(data.length>1){
var csv=“”;
对于(变量行=0;行
我认为在您的情况下,使用
getDisplayValues()
而不是
getValues()
可能会解决您的问题。这个怎么样?相关线程是