I've just been trying unsuccessfully to get phpexcel (PHPExcel_Writer_Excel2007) to automatically adjust row height based on content, when that content contains newline characters. At the moment, only the final line is visible. I've tried setting the row height to -1 for the row in question and the whole column i.e.
$objPHPExcel->getActiveSheet()->getRowDimension(65)->setRowHeight(-1);
and
$objPHPExcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(-1);
but it makes no difference. Help appreciated. Cheers
Related
In one of our pages I've created a detail screen with some information divided in blocks. I've used HorizontalLayouts with setExpandRatio for this. Here is how this is divided (all values made black for privacy reasons):
The final Label of the second row (now containing ---) should actually be empty instead. All the blocks are basically Vaadin Labels, with values in it. However, these values can sometimes be null, in which case I don't want to show anything in the Label.
When I use an empty String however instead of ---, it will look like this:
As you can see at the final Label of the second row, it is now missing it's border (and possible other styles we might add in the future), because Vaadin automatically put the expandRatio of Labels with an empty input to 0, turning the width to 0px.
I know you can set the actual width of a Label as filler, but in this case it's simply a question whether the value that's supposed to be in that Label is or isn't null.
I've also tried a space as value, but it just ignores it and behaves the same as the empty value. And when I " " as value (without setting the Label to HTML-mode), it outputs this literally as on the screen.
Is there any value I could use for the Label when the value is null to still show the style with borders, but without value?
EDIT: Hmm, when I use and set the ContentMode of the Label to HTML it seems to work. Is this the intended work-around for this issue (which means I'll have to set ContentMode to HTML for all Labels with the potential of containing an empty value), or is there another workaround by changing this 'empty' value alone?
Ok, I ended up using my solution provided in the EDIT. For all these Labels I had already created a BorderedLabel class, so I simply added setContentMode(ContentMode.HTML); to it, and used when the value is null in our util helper class.
I have tableView with first column for row number. I would like to set CONSTRAINED_RESIZE_POLICY for all columns without first.
I made:
//First column implementation
column.setPrefWidth(40);
column.setResizable(false);
... //Make other columns
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
So I have first column with width I chose but other are wider than without last line in code above but still there is one additional void column.
And I have another question because I looked for resizing column to length of the longest text in column (I need it for first column) but I only found old answers with very long and tricky solutions. Is there any simple solution (method) to do it?
Edit: I found that when I try to manually resize columns, that they resize properly (as they should with CONSTRAINED) after only click to resize one of columns so I have a question, why they didn't resize from the start like I described above but after trying to manual resize. I think that problem is with setResizable false on first column but how can I repair this?
I found solution. To make other columns CONSTRAINED_RESIZE_POLICY there must be set size of the first column like below:
column.setMinWidth(40);
column.setMaxWidth(40);
and it's working without line setResizable(false).
In PHPExcel is there any format available to get proper reading of the order item value as shown in picture.
I read whole the document but not find any solution for this problem.
For the date filled also if the data is shown ###### like way then how to get that as well?
In MS Excel, numbers that are larger than a certain size will be shown in scientific format (e.g. 1.40E+15) unless you set a format mask for that cell which says otherwise. The solution is to set an appropriate format mask, or to set the value as a string value.
In MS Excel, if a string value is wider than the column size, then it will be shown as ######. The solution is to increase the column size.
EDIT
I can't tell you what the best column size is? That all depends on your data.... but you can either set columns to a fixed size using:
$objPHPExcel->getActiveSheet()
->getColumnDimension('D')
->setWidth(32);
or set a column to autocalculate the width
$objPHPExcel->getActiveSheet()
->getColumnDimension('D')
->setAutoSize(true);
Exactly as described in the PHPExcel docs
Note that we do spend time and effort writing this documentation to try and answer your questions: it is worth reading.
I have a QTableWidget that is used to display lots of data, basically derived from a function f(a,b). All a values go into the horizontal header, all b values into the vertical header and all f(a,b) into the corresponding cell.
The columns should be sortable. When a user clicks a column, all values in that column are sorted and all other columns are also "synchronized", since whole rows are sorted (using the clicked column as a sort criterium).
This works. Except for the "header column", the vertical header. The vertical header does not change, it does not synchronize with the reorganized rows. Is this the intended behaviour? Is it a bug in my code? How do I make the vertical header sort, too? Or do I need to add my b's to an ordinary column?
edit: I solved it now by making the header column an ordinary column. Though, I would still be interested in why the vertical header does not sort with the other columns.
Try to use QTableView instead of QTableWidget.
And use QAbstractTableModel for computing f(a,b)
I use a subclassed QTableWidget with QTableWidgetItems in cells to display certain data. In the first row, I have a set of numbers separated by new lines in each cell. My problem is that when I increase font size/decrease cell size, some lines completely disappear, allthough the cell is definitely high enough to contain them.
This usually appears when there is a 2-digit number with some other lines under it and (probably) the font size is greater than the box width can match. I have the elide mode set to none to suppress the "three dots" that appear when this happens.
this->setTextElideMode(Qt::ElideNone);
The first row is resized by
this->resizeRowToContents(0);
this->setRowWidth(0, this->rowWidth(0) + 10);
so that its high enough.
However, the numbers keep on disappearing. Example shown here, note the font size change and missing numbers.
http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug1.png
http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug2.png
I'm starting to be quite desparate about this...any help highly appreciated.
Just to investigate the problem, try:
Make shure that string is correctly created (2,5,10,3) and not (10,3)
Try letters instead of numbers to make shure that they are shown
Try use 3digits nuber alongside with 2digits and see what is happened
May be workaround this by using 01,02 numbers?
Try resizeColumnsToContents() instead of setColumnWidth. If that doesn't work, try calling resizeColumnsToContents() before resizeRowToContents(0).
By the way, is there any reason for calling resizeRowToContents(0) instead of resizeRowsToContents() (note the different name)?