Does the width of a Table2 or a Cell2 include the border? For a Cell2, does it include the padding? - dynamicpdf

I'm working with the DynamicPDF library to typeset tabular data and I have an incomplete understanding of how the width property of Table2 and Cell2 objects works. Specifically, I don't know whether the width set by the property is an internal width, or an external one. For a Table2 object, I don't know whether it includes the left and right borders of the table. For a Cell2 object, I don't know whether it includes the left and right borders or whether it includes the left and right padding. For that matter, I have an incomplete understanding of why we are permitted to set the width of the table at all - surely the width follows logically from the widths of the table columns, in which case the proper way to modify the table's width is by modifying the column widths?
It would be useful to know whether the table width in particular includes its borders, because I want to typeset tables that are the width of the page (or rather, the width of the area inside the page margins). If the Table2's width propery includes the border width, then the correct way to do this is to set the width to the page width. If not, then the correct way is to subtract the left and right border widths first. If I do it wrong, then the table will be either too wide or too narrow.
These pages seem to be up-to-date documentation, but they don't specify whether the borders/padding are included (they just say "Gets or sets the width of the table." and "Gets the width of the cell.") This page has examples of use of the Table2 class, but all of them use hard-coded widths.

The table width is independent of column widths. Table width cannot be modified by modifying the column widths. When generating the tables with dynamic data, setting table width allows you to specify a region in which the content is rendered and anything that falls outside of these boundaries is overflowed into a new table. For example if the sum of the column widths is greater than the table width, the columns that do not fall within the table boundaries are pushed out into the overflow table which can be accessed using GetOverflowColumns().
Border width is not included in the table width. On the other hand, cell width includes the cell border width and padding of the cell. Here is the code that demonstrates how different widths are set.
Document document = new Document();
Page page = new Page();
Table2 table = new Table2(0, 0, 300, 500);
table.Border.Width = 5;
table.Border.Color = RgbColor.Red;
table.Columns.Add(100);
table.Columns.Add(100);
table.Columns.Add(100);
Row2 row = table.Rows.Add();
Cell2 cell = row.Cells.Add("Cell 1");
cell.Padding = 5;
cell.Border.Width = 5;
cell.Border.Color = RgbColor.Blue;
Cell2 cell2 = row.Cells.Add("Cell 2");
cell2.Padding = 5;
cell2.Border.Width = 5;
cell2.Border.Color = RgbColor.Green;
Cell2 cell3 = row.Cells.Add("Cell 3");
cell3.Padding = 5;
cell3.Border.Width = 5;
cell3.Border.Color = RgbColor.DarkOrange;
page.Elements.Add(table);
page.Elements.Add(new LayoutGrid());
page.Elements.Add(new Label("Table Width: " + table.Width.ToString(), 0, 50, 200, 20));
document.Pages.Add(page);
document.Draw("Table2.pdf");
Disclaimer: I work for ceTe Software, the company that develops DynamicPDF libraries.

Related

How to use Conditionally Formatted Data bars on three leveled grouped rows that are populated with data on the fly

I have a situation where there are rows grouped at three levels. The data is populated dynamically. Currently, I am able to assign conditionally formatted data bars across the whole column (Col Q). But, I want different colored data bars for each level of rows. See in the picture below, I want data bars for all red colored rows to be in red color (Row 47), data bars for purple colored rows to be in purple color. What I have right now is purple all the way.
* UPDATE *
This is the code block I have for all the red rows. Somehow, the bar size is not reflective of the value present in the corresponding cell.
Set db = Worksheets("Deliverable-Epic-Story Progress").Cells(delvRow, delv_StatusCell + 1).FormatConditions.AddDatabar()
db.BarColor.Color = vbRed
db.MinPoint.Modify newtype:=xlConditionValuePercent, newvalue:=0
db.MaxPoint.Modify newtype:=xlConditionValuePercent, newvalue:=100
Modified the code block to this. I added the format via code. Changed the min and max values.
Cells(delvRow, delv_StatusCell + 1).NumberFormat = "0%"
Set db = Worksheets("Deliverable-Epic-Story Progress").Cells(delvRow, delv_StatusCell + 1).FormatConditions.AddDatabar()
db.BarColor.Color = vbRed
db.MinPoint.Modify newtype:=xlConditionValuenumber, newvalue:=0
db.MaxPoint.Modify newtype:=xlConditionValuenumber, newvalue:=1

Spotfire Table Visualization column width

Is there a way to set Spotfire Table visualization column width either through Java or Python script. i can able to change the column width manually but whenever the value changes through property control it reset again. I need to set constant column width. Thanks in advance.
from Spotfire.Dxp.Application.Visuals import TablePlot
# Tab is the (Visualization) parameter passed to the script specify the table to work on
dataTable= Tab.As[TablePlot]().Data.DataTableReference
# Get a handle to the Table plot
table = Tab.As[TablePlot]()
# Get the ColumnCollection for the Table plot
columns = table.TableColumns
# Size all of the columns
for x in columns:
x.Width = 200
good question! you can add an IronPython script (I don't believe it's possible to do this using Javascript unless you are some kind of wizard, or otherwise hate yourself :) to do this pretty simply.
I'll put the examples all in one code snippet, but obviously you would only want to do one of these loops at a time. the snippet expects a parameter called viz whose value is the TablePlot visualization you wish to modify.
from Spotfire.Dxp.Application.Visuals import TablePlot
v = viz.As[TablePlot]()
# increase all column widths by 10 pixels
for col in v.Columns:
col.Width = col.Width + 10
# set all column widths to 100 pixels (the default value)
for col in v.Columns:
col.Width = 100
# set the width of a specific column to 50 pixels
for col in v.Columns:
if col.Name == "My Column":
col.Width = 50

SSRS: Excel-Rendering always created an empty Column

I have a strange problem with the SSRS-Excel Renderer:
As soon as I create a Table, it can be empty, with more than one Column, at the most right column, an empty Excel-Column shows up:
In the example, I just putted a plain Table into the RDLC, added the hardcoded values 1 to 4, and you can see, there is the 'C`Column pretty small, but without any values anywhere in it.
As per my understanding this is possible only if Report width is greater than tablix width,
Just Make sure you have same width for both Report & Tablix, Report width is in pt but tablix Size.width in inch.. so use any conversion and set same width for both.
Roughly 1 inch= 72 pt

How to Set the Background Color of a Cell in a MigraDoc Table

I have a MigraDoc table where I specify a row height of 0.75cm, and the text is vertically-aligned in the middle of the cell. When I set cell.Format.Shading.Color to something non-white, there is still a portion of the cell near the border that is shown as white around all four sides.
I discovered I can remove the white section to the left and right of the text by setting column.LeftPadding = 0 and column.RightPadding = 0. However, I cannot figure out how to get the white stripes at the top/bottom of the text to disappear without affecting the vertical alignment of the text. If I change the paragraph line height to 0.75cm, the stripes disappear, but the text is then bottom-aligned within the cell. I cannot set the column shading color because each cell in the column contains a different color. Does anyone know a way to force the paragraph to fill the cell vertically (or otherwise get the background color to be uniform within the cell)?
Here is a sample of my code (in C#) where table is of type MigraDoc.DocumentObjectModel.Tables.Table:
...
// Add a column at index #2
var column = table.AddColumn();
column.LeftPadding = 0;
column.RightPadding = 0;
// Add more columns
...
// Iterate through the data printed in each row
foreach (var rowData in myData)
{
// Create a row for the data
var row = table.AddRow();
row.Height = ".75cm";
row.Format.Font.Size = 11;
row.VerticalAlignment = VerticalAlignment.Center;
...
// The following is for illustrative purposes... the actual
// colors and text is determined by the data within the cell
var cell = row.Cells[2];
cell.Format.Shading.Color = Colors.Black;
cell.Format.Font.Color = Colors.White;
var paragraph = cell.AddParagraph("Example");
...
}
Try cell.Shading.Color instead of cell.Format.Shading.Color - the former sets the colour of the cell, the latter sets the colour of the text background (and the padding of the cell will then have a different colour).

How to resize the widget that hold a QTableView?

I have a QTableView inside a layout itself inside a Widget.
How I can set the Widget size after the call of tableView.resizeColumnsToContents() in order to have the same size of the table (and does not need a scrollbar )
Thanks
If I understand properly what you want is to adjust the horizontal size of the container widget to the size of the table contents (which is not necessarily the table size). The following method works for me with a small table of 20 rows and 3 columns:
ask the table model for the total number of columns (it should be returned by your implementation of the columnCount method)
ask the view for the width of every column using the columnWidth method and compute the total width of the columns
finally resize your container widget taking into account the total width of columns, the width of the table vertical header and the autoscroll margin
So the code would look like:
my_table_view.resizeColumnsToContents()
w = 0
for c in range(my_table_model.columnCount()):
w = w + my_table_view.columnWidth(c)
container_widget.resize(w + my_table_view.verticalHeader().width() + my_table_view.autoScrollMargin()*1.5, container_widget.size().height())
As I said, I'm assuming that you want to resize your widget horizontally.

Resources