如何在电子表格中将十进制数转换为时间

时间:2013-06-25 06:49:26

标签: google-apps-script google-sheets google-docs

通过Table Capture扩展程序,我已将网页中的html表复制到google电子表格中。 在该表中,有一个小数点的列,例如:

12.4

我想将其更改为

12:40:00

如果我通常将.替换为:,那么它将替换为

12:04:00

1 个答案:

答案 0 :(得分:0)

您应该试试Format => Number => Time

您应该Tools =>打开一个新脚本Script Editor并查看that这是删除行的教程,您需要对其进行调整以更改行值。您将找到所有需要的文档here

您的代码可能如下所示:

for each row{
    var string = new array(2);
    //Split the string a the .
    string = row.split(".");

    // if the second part is like 4 in 12.4 you set it to 40
    if (string[1].lenght() == 1)
        string[1] += 0;

    // Set the row value to the format you like, here : 12:40:00
    row.setValue(string[0] + ":" + string[1] + ":00");
}