문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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');  
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top