Pergunta

I am building my very first Google Scripts Web App.

I am using a FlexTable in a Google Apps Script to display my content.

I have been merrily using the following to set a variety of CSS styles for my content in the cells:

FlexTable.setStyleAttributes(row,col,{attribute: "value"});

However, it does not seem to respond to marginLeft nor marginRight at all. How can I center the contents of a FlexTable cell?

Thank you for your kind consideration.

Foi útil?

Solução

OK, I have the answer. I was successfully aligning the text within the cell. However, it appeared that I was not because the CaptionPanel was left-justifying my FlexTable.

Note: I figured this out by assigning a high contrast background color to the FlexTable cell.

My solution (perhaps just a workaround) was to use setWidth to make the FlexTable cell fill the width of the CaptionPanel.

Thank you, Sam, for the conversation. Your feedback helped me sort out the issue by helping build confidence that what I was doing with the FlexTable was correct.

Outras dicas

The code below works for text in flextable cells.

//center for row
flexTable.setRowStyleAttribute(0, 'textAlign', 'center');

//for cell
flexTable.setText(0, 0, "Some Text").setStyleAttribute(0, 0, 'textAlign', 'center');  
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top