我是一个初学者,正在寻找一些帮助来设计由 Google Apps 脚本生成的表格,它是一个显示 Google 联系人列表的表格,并从这个站点的代码开始。
我一直在尝试通过添加.setStyleAttributes({})
to来设置它的样式app.createGrid
,但我似乎无法找到一种方法来定位所有浏览器上的元素。当前页面在 Chrome 中看起来不错,但我什至无法在 Firefox 中折叠边框...grid.setWidget
app.createLabel
<td>
我想要的是能够:
- 让 Firefox 上的边框崩溃(现在完成,谢谢)
- 设置单元格边框的样式以获得水平蓝线且没有垂直线(或白色垂直线)
无论如何,这是生成表格的代码,任何建议或帮助将不胜感激。
//Create grid to hold the contacts data, styles set <table> inline styles
var grid = app.createGrid(sorted_contacts.length+1,6)
.setBorderWidth(1)
.setCellPadding(5)
.setStyleAttributes({borderCollapse: "collapse", border: "1px solid #D1E2FF", borderBottom: "1px solid #D1E2FF", borderTop: "1px solid #D1E2FF", borderLeft: "1px solid #fff", borderRight: "1px solid #fff"});
//Create the header row
grid.setWidget(0, 0, app.createLabel('Name').setStyleAttributes({fontFamily: "Verdana, sans-serif", fontWeight: "bold", color: "#384C80"}))
.setWidget(0, 1, app.createLabel('Email').setStyleAttributes({fontFamily: "Verdana, sans-serif", fontWeight: "bold", color: "#384C80"}))
.setWidget(0, 2, app.createLabel('Home').setStyleAttributes({fontFamily: "Verdana, sans-serif", fontWeight: "bold", color: "#384C80"}))
.setWidget(0, 3, app.createLabel('Work').setStyleAttributes({fontFamily: "Verdana, sans-serif", fontWeight: "bold", color: "#384C80"}))
.setWidget(0, 4, app.createLabel('Mobile').setStyleAttributes({fontFamily: "Verdana, sans-serif", fontWeight: "bold", color: "#384C80"}))
.setWidget(0, 5, app.createLabel('Address').setStyleAttributes({fontFamily: "Verdana, sans-serif", fontWeight: "bold", color: "#384C80"}))
//Write all the contacts in grid/table
for (var i=0; i<sorted_contacts.length; i++){
//Display the first name + surname or just the surname
if(sorted_contacts[i][0]!='') grid.setWidget(i+1, 0, app.createLabel(sorted_contacts[i][0]+' '+sorted_contacts[i][1]).setStyleAttributes({fontFamily: "Verdana, sans-serif", color: "#2E2E2E"}));
else
grid.setWidget(i+1, 0, app.createLabel(sorted_contacts[i][1]).setStyleAttributes({fontFamily: "Verdana, sans-serif", color: "#2E2E2E"}));
//Display the rest of the fields
grid.setWidget(i+1, 1, app.createLabel(sorted_contacts[i][2]).setStyleAttributes({fontFamily: "Verdana, sans-serif", color: "#2E2E2E"}));
grid.setWidget(i+1, 2, app.createLabel(sorted_contacts[i][3]).setStyleAttributes({fontFamily: "Verdana, sans-serif", color: "#2E2E2E"}));
grid.setWidget(i+1, 3, app.createLabel(sorted_contacts[i][4]).setStyleAttributes({fontFamily: "Verdana, sans-serif", color: "#2E2E2E"}));
grid.setWidget(i+1, 4, app.createLabel(sorted_contacts[i][5]).setStyleAttributes({fontFamily: "Verdana, sans-serif", color: "#2E2E2E"}));
grid.setWidget(i+1, 5, app.createLabel(sorted_contacts[i][6]).setStyleAttributes({fontFamily: "Verdana, sans-serif", color: "#2E2E2E"}));
}
//add the grid/table to the panel
panel.add(grid);
//add the panel to the application
app.add(panel);
return app;