I have a table in Word filled dynamically, I need to make the last cell or row fills the height of the remaining space in the page like this.
so when new row created the it still in the same page and reduce the last cell's height.
Related
I'm creating a UItableView with two different dynamic custom cells and want both cells to have different default height. I can't seem to do this since the cells always take the height specified in the table view row height option instead of the table view cell height option.
I used AQGridView for showing record in GridView. I want to customise all cell size. But AQGridView always take constant cell size and showing empty space if records view is small size.
I am creating one pdf file showing a list of all employees and their salaries. At the end of the page it is showing the total of all salaries.
I am using a for loop to add multiple rows to table.
The problem is:
at the end the row, the total salary doesn't fit on the same page and it is shown on the next page.
So is there any way that I can calculate the height of the page and then fix the height of each cell? And then accordingly, limit the number of rows.
So that at the end of the page, I can show the total number of rows and further record from next page.
Calculate the height of the page: well... you decide on the size of the page when you create a Document object. You can choose any size you want.
Calculate the height of a PdfPTable: that's explained in chapter 4 of my book. When you create a PdfPTable, you add PdfPCell objects to an object that only exists in memory and that doesn't know anything about page size. By default, the width is expressed as a percentage of the available width of the page to which you'll add the PdfPTable. Only when you add the PdfPTable to a specific Document, the exact width and the height will be calculated (which is too late for you).
If you want to know the height in advance, you need to define an absolute width (not a percentage). Tables with the same content and a different width will have a different height. Defining an absolute width is done like this:
table.setTotalWidth(width);
table.setLockedWidth(true);
In this snippet (taken from the TableHeight example), width equals the width of the page minus the left and right margin. You're defining the width of the page and the margins upon creation of the Document object. By default, the page size is A4, so the default width is 595 user units and the default margins are 36 user units.
So, one way to solve your problem, would be to add rows in a loop and calculate the height of each row with the getRowHeight() method or the height of the complete table with the getTotalHeight() method (both methods will return 0 if you omit setting the total height). If you see there's not enough space to add the summary row, you can use the deleteLastRow() method to remove that last row and to create it anew in a new table on the next page.
That's one solution. Another solution could be to use table and cell events, but that's more difficult to explain.
I am creating a one column PdfPTable given a Rectangle, at a particilar absolute position. In this table, I need to add a collection of PdfPCells and show as much of the cell content as possible and the cells must be clipped at the table rectangle boundaries. I took care of the width by:
PdfPTable cutTable = new PdfPTable(1);
cutTable.setTotalWidth(200f);
cutTable.setLockedWidth(true);
I have a phrase object in each cell and I add a set of cells to the table. The problem is that the cells overflows the table height boundary and it is not clipped. I tried keeping track of the total cells' height after adding each cell, but the problem is that since I ask the table for the row height, a cell must be inserted before and my calculation is off as the last cell overflows.
How do I get the table to clip the cell contents at its boundaries? If I can't do this, how do I determine the height of the cell(the phrase uses Arial 8 font) with the default text wrapping, before it is added to the table?
Thanks in advance for your help.
Take a look at the CellHeights example from my book "iText in Action." It uses the different options to set the height of a cell. I think you need the setFixedHeight() method. When using this method, all content added to the cell that doesn't fit the height will be dropped.
I need to display a spreadsheet in a view. There's no need to edit the cells of the spreadsheet, and the spreadsheet will consistently have the same number of rows and columns. (The spreadsheet cells will be populated with financial figures generated by the user in a different view)
How would I do this? A UITableView seems inadequate, as there need to be around 70-80 cells displayed in this table.
One way to do it is to write your own table cell to contain all the columns in a particular row. Then you can load the cell for each row in UITableView
If the cells don't need to be editable, they don't contain images, and the number of cells isn't large, you could just use labels or drawn text inside a grid of framed rectangles in a UIView, and display that larger view inside a UIScrollView.