How to call getDefaultRowHeightByFont() function correctly in phpspreadsheet - phpexcel

I am writing to excel row by row and try to get current row height after write to each row.
I tried use getDefaultRowHeightByFont() to get default row height based on font type.
$font_type='times new roman';
$sheet->getDefaultRowHeightByFont(\PhpOffice\PhpSpreadsheet\Style\Font.$font_type)
The row height should be exact value that we get when manually check for row height in excel sheet. But, I got the error
Call to undefined method PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::getDefaultRowHeightByFont()
How to call that function correctly?
Thanks in advance.

Able to make it run.
use PhpOffice\PhpSpreadsheet\Shared\Font as SharedFont;
$default_rowheight=SharedFont::getDefaultRowHeightByFont($spreadsheet->getDefaultStyle()->getFont());
But, this method only show row height for default font style in that sheet. So, we could not find accurate row height for row with different font style from default.

Related

How to increase row height in vaadin grid accordingly to data in the cell

I am consuming data from the list and some list may contain multiple line data, so how that can be reflected in the vaadin grid at runtime.
This is the code
public Grid GridBasic() {
grid.removeAllColumns();
grid.addColumn(TopicConsumedDetails::getPartitionNumber).setHeader("PARTITION ");
grid.addColumn(TopicConsumedDetails::getOffset).setHeader("OFFSET");
grid.addColumn(TopicConsumedDetails::getMessage).setHeader("MESSAGE");
grid.setItems(details);
grid.addThemeVariants(GridVariant.LUMO_WRAP_CELL_CONTENT);
grid.getColumns().forEach( col -> col.setAutoWidth(true));
return grid;
}
This just displays all the data in a single line and it requires scrolling left to right.
Vaadin Version :23.3.1
Use the built-in "wrap cell content" variant: https://vaadin.com/docs/latest/components/grid/#wrap-cell-content
grid.addThemeVariants(GridVariant.LUMO_WRAP_CELL_CONTENT);
As per the previous answer, I think that using this is the correct approach:
grid.addThemeVariants(GridVariant.LUMO_WRAP_CELL_CONTENT);
However, you are overriding this setting by calling
grid.getColumns().forEach( col -> col.setAutoWidth(true));
According to the documentation, this automatically sets the column width based on the contents, leading to the right scroll problem.
If you remove this call, you should get the proper wrapping behavior. I was able to reproduce the problem and then see a result like this once I removed the auto width setting:
Alternatively, if you have sensible line breaks in the content you want to wrap, you can do that--but it won't happen automatically, as mentioned by #Rolf in a comment above. That is because the line breaks in the text are basically just whitespace and aren't respected as such by the HTML. So in order to do that, one option is to add an "Html" component column. You can then replace your text's line breaks with <br/> tags, which you could do with a regular expression. It would look like this:
String myColumnText = colText.replaceAll(....); //Some regex to match on your particular line breaks
grid.addComponentColumn(item -> new Html("<p>" + myColumnText +"</p>");
The <p> tags (or some wrapper tags) are required as the Html component requires a wrapper tag.
Note that (1) using this approach means that you won't get the automatic wrapping behavior any more so the line breaks in your source need to be sensible and (2) you have to be certain you trust the incoming content or it is otherwise sanitized, as this kind of rendering-text-as-html opens up some security holes with untrusted content.

ExtJs 6: how to directly get specific grid cell component by known position

I have a simple grid and would like to manage some specific cell.
Here it is: https://fiddle.sencha.com/#fiddle/32q1
I know its row number and column name.
But how I can directly get cpecific cell as a component?
I need to make setEnable and setStyle to it.
I used the getCell method from the Ext.view.Table (https://docs.sencha.com/extjs/6.2.0/classic/Ext.view.Table.html#method-getCell)
Your code could look like this:
let grid = Ext.getCmp('mygrid'),
column = grid.getView().getGridColumns()[1],
record = grid.getStore().getAt(2),
cell = grid.getView().getCell(record, column);
Here is the Fiddle for it.

Display cumulative value of each column in balloon text

I built a cumulative line graph using context.cumulativeCol() in the Value field and I am interested in displaying the cumulated value of the current column in the ballon text.
This is what I have, which only shows the value of the column:
I tried to change the default value [[Row]], [[Column]]: [[Value]] from the Ballon Text field and tried to use something like context.cumulativeCol() but I could not achieve my goal.
If it is possible, how am I supposed to do it?
I've just tried to put:
return "Cumulative: " + context.cumulativeCol();
to the balloon function and it worked fine in the latest version. Perhaps you are trying to return a number instead of a string from the balloon function?

How to get text rendered in the cells?

How can I get text rendered in the cells? I have tried the following :
[1] $(gridId).jqxGrid('getcellvaluebyid', rowID, columnFields[j])
[2] $(gridId).jqxGrid('getcelltextbyid', rowID, columnFields[j])
However, I only get the actual values of the cells like flags and status codes instead of the actual flag names and status names rendered on the specific cell (using cells renderer).
Please help.
Have you tried by creating an Array variable and caching the cellsrenderer result using that Array. After that you can access the rendered cell content using your Array and your array keys.

QTP - getting value of element

I am beginning with QTP and just cannot find out how to get value of element. For example when I just want to compare the number of results found by google. I tried to select the element with object spy and use Val(Element) to assign the value into variable..but it doesnt work. Could anyone help with this? BTW, I am not sure whether selecting the text (element) to compare with Object spy is correct.
Thanks!
You should use GetROProperty in order to get the text and then parse it for the value.
Looking at a Google results page I see that the result is in a paragraph with id=resultStats in the 3rd bold tag.
<p id="resultStats"> Results <b>1</b> - <b>10</b> of about
<b>2,920,000</b>
for <b>qtp</b>. (<b>0.22</b> seconds)</p>
So the following script gets the number (as a string with commas).
Browser("micclass:=Browser")
.Page("micclass:=Page")
.WebElement("html id:=resultStats")
.WebElement("html tag:=b","index:=2").GetROProperty("innertext")

Resources