我正在制作一张主表, 将UiApp嵌入到活动表中。我已尝试使用第一行中的标签对第一部分进行编码,但我仍然坚持将名称[i]显示在任务标签下的表格的左侧。
我打算为每个任务标签下的每个名称显示复选框。
以下是代码:
function showTable()
{
var ss = SpreadsheetApp.getActive();
var TL = ss.getRange('B3').getValue();
//SetFontWeight("bold") for TL < *This does not work either* >
var startDate = ss.getRange('B2').getValue();
var strStartDate = startDate.getDate() + "/" + (startDate.getMonth() + 1) + "/" + StartDate.getFullYear();
var counta = ss.getRange('B4').getValue();
var app = UiApp.createApplication().setHeight(375).setWidth(620)
.setTitle('This is ' + TL + "'s Team Tasks for " + strStartDate);
var panel = app.createAbsolutePanel().setId('panel').setHeight(355).setWidth(605)
.setStyleAttribute('background', 'lightCyan');
var names = ss.getRange('B11:B').getValues();
for (var i = 0; 0 < names.length; i++) **//This is the part that does not work**
{
var agents = app.createLabel(names[i]);
}
var handler1 = app.createServerHandler('btnCloseWindow');
var btnCloseWindow = app.createButton('Close Window').addClickHandler(handler1).setStyleAttribute('background', 'lightYellow');
handler1.addCallbackElement(panel);
var myLabel0 = app.createLabel('Tasks');
var myLabel1 = app.createLabel('HW');
var myLabel2 = app.createLabel('MU');
var myLabel3 = app.createLabel('MOV');
panel.add(myLabel0, 40, 12)
panel.add(myLabel1, 100, 12)
panel.add(myLabel2, 140, 12)
panel.add(myLabel3, 175, 12)
panel.add(agents, 40, 30)
panel.add(btnCloseWindow, 490, 320)
app.add(panel);
ss.show(app);
return app;
};
function btnCloseWindow(e)
{
var ss = SpreadsheetApp.getActive();
var app = UiApp.getActiveApplication();
app.close();
return app;
};
如何制作带有名称的垂直面板? 名称在col B11:B中定义,任务在标签中定义。
这是我第一次制作UiApp,所以非常感谢任何帮助!
答案 0 :(得分:0)
尝试这样,我不知道整个想法应该是什么样子,但名单上的部分现在是正确的......
function showTable()
{
var ss = SpreadsheetApp.getActive();
var TL = ss.getRange('B3').getValue()
ss.getRange('B3').setFontWeight('bold')
var startDate = ss.getRange('B2').getValue();
var strStartDate = Utilities.formatDate(startDate, ss.getSpreadsheetTimeZone(), 'dd/mm/yyyy');
var counta = ss.getRange('B4').getValue();
var app = UiApp.createApplication().setHeight(375).setWidth(620)
.setTitle('This is ' + TL + "'s Team Tasks for " + strStartDate);
var panel = app.createAbsolutePanel().setId('panel').setHeight(355).setWidth(605)
.setStyleAttribute('background', 'lightCyan');
var handler1 = app.createServerHandler('btnCloseWindow');
var btnCloseWindow = app.createButton('Close Window').addClickHandler(handler1).setStyleAttribute('background', 'lightYellow');
handler1.addCallbackElement(panel);
var myLabel0 = app.createLabel('Tasks');
var myLabel1 = app.createLabel('HW');
var myLabel2 = app.createLabel('MU');
var myLabel3 = app.createLabel('MOV');
panel.add(myLabel0, 40, 12)
panel.add(myLabel1, 100, 12)
panel.add(myLabel2, 140, 12)
panel.add(myLabel3, 175, 12)
var names = ss.getRange('B11:B').getValues();
Logger.log(names)
for(i=0;i<names.length;++i){
Logger.log(names[i][0]);// names is a 2D array, you only want the first and only column
if(names[i][0]!=''){ // don't show if empty
panel.add(app.createLabel(names[i][0])); //add label to the panel
}
}
panel.add(btnCloseWindow, 490, 320)
app.add(panel);
ss.show(app);
};
答案 1 :(得分:-1)
var names = ss.getRange('B11:B')。getValues();
应该是,
var names = ss.getRange('B11:B1').getValues();
我是如何研究的,
var data = ss.getRange("b11:b1").getValues();
data.forEach(function(element,index,array){Logger.log(index + " " + element )});
记录,“0只狗 1只猫 2青蛙 3条鱼 4只仓鼠 5条狗 6只猫 7青蛙 8条鱼 9只仓鼠 10只狗“