Question

It appears there is no way to style individual cells (to, say, change the background color of a header row, for example) within a GAS FlexTable. Is that correct?

The only methods I see here are .setStyleAttribute() and .setStyleAttributes() both of which operate on either the entire application or the entire flextable as the object.

Furthermore, I see no methods that return an individual cell or subset of cells from the flextable such as a .getCell() or .getRow().

Therefore, am I correct in concluding that there is no way at this time to set the style of an individual cell in a GAS flextable? (Sorry if the answer to this question is an obvious, “There is no way to do it.” But I figured I had better check with the experts first before giving up.)

Was it helpful?

Solution

Setting style to individual cell is done with:

method setStyleAttribute(row, column, attribute, value) - Sets a CSS style on a cell of this FlexTable.

You have to scroll down to the second occurence of setStyleAttribute on the FlexTable page. Since the HTML anchor is #setStyleAttribute for both methods you always get the first.

A getCell method would not be useful as a flextable cell is no widget.

There is also a setStyleAttributes(row, column, attributes) method ...

OTHER TIPS

setWidget is expensive

I pull out about 500X12 table in flextable and found use setText is at least twice times faster.

Then again, I also can not figure out how to change font size in flexTable while calling setText. The background, font color etc worked, but not font size.

There is a very easy way to do this. Instead of using FlexTable.setText() to set the contents, use the FlexTable.setWidget() instead. And you can add a label and style it however you want to and each label can have its own style

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top