valign images in xlsxwriter cell - xlsxwriter

Is there any hack for v-aligning images in a cell
I am trying to create a dashboard,those traffic lights are images.
Since once of the columns is a text-wrap and the height of those rows
are dynamic, I have no way of knowing the row height to calculate the y_offset for those images
Does anyone have a recommendation on how I can handle this? Is there a way of getting the row_height after sheet.write and text_wrap format is applied?

Is there a way of getting the row_height after sheet.write and text_wrap format is applied?
Probably not without access to Windows APIs for calculating bounding boxes for strings.
You could probably make some working estimates based on the length of your string. Each new line in text wrap is equal to 15 character units or 20 pixels.
Since once of the columns is a text-wrap and the height of those rows are dynamic, I have no way of knowing the row height to calculate the y_offset for those images
This is the main problem. In order to specify the image position exactly you will need to specify explicit row heights so that XlsxWriter can calculate where the image will go based on the size of the cell. In order words you will have to avoid the automatic row height that Excel gives you when wrapping text.
Once the row height is fixed you can position images exactly where you want them using the 'x_offset' and 'y_offset' options.
Note, you can also use conditional formatting to create traffic lights based on cell values. See Sheet9/Example 9 of this code from the XlsxWriter docs and image below. These can be centered automatically even with with text wrapping.

Related

Can VBA detect line-wrapping in an Excel chart legend?

Context
Writing to code to format a chart (all of which should be done by Microsoft, but that’s separate).
Am now positioning the legend. Taking a 9×9 block of possible positions, and counting the data points underneath each. As a fragment of the code: (ax.MaximumScale - ax.MinimumScale) * co.Chart.Legend.Width / co.Chart.PlotArea.InsideWidth.
Also coping with lines underlapping and text boxes overlapping the possible legend positions: same idea, more complexity.
Question
Obviously, all this works better if the legend is as small as possible, as that gives a greater likelihood of finding a location with zero ’lapping.
If .Legend.Width is too small, then the individual legend texts (the Series.Name’s) wrap onto ≥2 lines, which isn’t wanted. So VBA could interval bisect to find the smallest .Legend.Width for which there isn’t line wrapping. But how can the VBA code ‘see’|‘detect’|‘know’ of the existence of the line wrapping?
And mutatis mutandis for .Legend.Height: if that’s too small, some legend entries aren’t shown. How can the VBA code ‘see’|‘detect’|‘know’ that a height is too small?
Thank you.
PS: I expect that the correct answer is that “VBA cannot ‘see’|‘detect’|‘know’ either of these.” Please refute this expectation.
If you create your own legend, using a text box, you have better options when it comes to sizing and flow control. This will create a new set of challenges, but it might be easier to handle.

Using BIRT, how can I ensure that the background colour in a row is the same height in each cell in the row?

I have a BIRT report that I have set up to use conditional formatting so that the colour of the row alternates between grey and white. It works as expected except for the fact that the grey colour in a field with a string extends slightly below where the grey extends in a field with an integer. In other words, if the grey background is 1 inch high with an integer, it is 1.1 inch high with a string. I cannot see any differences in any of the margin or padding settings so I am not sure what would be causing this small issue.
It is easy to be confused with styling, because we can set style properties on rows, cells or data fields within cells.
As you describe this issue, i think you have not applied this conditional formatting on rows, but on cells or data fields.
When a BIRT table is selected in the outline view of Eclipse designer, we need to click on the left to select the whole row, and then define a conditional formatting. Thus, physically we can't have height differences between cells (at least in html format) because the style is applied on a "div" container.

UITableView height of a section

I have a UITableView that has 3 sections. My individual cells vary in height (collapse-expand).
I need a way to figure out the height of each individual section, i.e. the sum of cell heights in each section. Preferably without calculating everything the tableView already has done each time I need it.
I there a way to deduce or access such a value?
Did you look at -rectForSection: (and possibly also -rectForFooterInSection:)?
There is no easy way to calculate the value, however there is a way. If your cells have a fixed height it's just the many rows multiplied by their fixed height for each section.
If you have varying height in the cells too, I'd go for an array which holds the total height for each section, just calculate it once and keep it cached there. If the section is collapsed you just need the section header height else it's the value in the array.

dojox.charting: how to align the plotArea of 2 charts, one above another?

I'm trying to layout 2 linked charts, one above the other, similar to what you might see on the Google Finance page.
I can render both charts just fine, but getting the plotAreas to line up exactly is a bit of a mystery. The chart.plotArea.width of each chart seems to depend on the width of my Y axis labels. Thus the 2 charts are not the same width and have different values for chart.getCoord().l.
Right now, I'm using an offset which is manually calculated, but there must be a better way.
this.chart.render(); // top chart, getCoords().w=800
// manually set margins for lower chart to match
this.chartVol.margins.l = this.chart.offsets.l - 59 + 10;
this.chartVol.margins.r = this.chart.offsets.r - 31 + 10;
// render bottom chart
this.chartVol.render(); // bottom chart same width, getCoords().w=800
There are two simple ways to do it:
Use maxLabelSize and labelFunc. The former is the maximal label's size in pixels. The latter is a function, which takes a number, and returns a corresponding string label.
Use labels, which is an array of {value, text} objects, and include one long dummy string of desired size at the end with some bogus value.
I don't recall how to do it without custom labels, so if you feel like it is really needed, please submit an enhancement ticket.

SSRS 2005 with matrix and list shows blank page between every data page when printing or exporting to PDF

I am using SQL Server Reporting Services 2005 - I have created a portrait A4 report 8.5in by 11in.
The report consists of a header, body and a footer.
The body consists of a number of textboxes in a 2 column layout and underneath them a matrix placed onto a list.
The matrix consits of 2 fixed rows (with 1 fixed textual column in the top row and 2 dataset field columns in the bottom one) and a number of columns (each with a width of 0.875in and data taken from different dataset fields). I use the group expression =Ceiling(RowNumber(Nothing)/5) on the list, to make the matrix columns start below the previous ones every 5 repeated columns.
The problem I am facing is that a blank page (with only header and footer) is appearing between every page of report data when I export the report to PDF or print it physically, if the matrix spans more than one page of data. There is plenty of room for the columns of the matrix on the page. I have tried the following, but to no avail:
1) I checked that Page Width (8.5in) >= Body Width (7.20833in) + Left Margin (0) + Right Margin (0)
2) I checked that Page Height (11in) >= Page.TopMargin (0) + Header.Height (2in) + Body.Height (6.60417in) + Footer.Height (0.89583in) + Page.BottomMargin (0)
3) I played around with various margin values, ranging from 0in to 0.5in for the left, right, top and bottom margins.
4) I set all textboxes' CanGrow property to false. This also has the undesirable effect of chopping out the text when it cannot fit, but even so, the blank page problem still occurs.
5) I placed the list and the matrix together in a rectangle with the blank space (to the right of the matrix) outside the rectangle.
The only thing that stops the blank pages from appearing is changing the list grouping expression to =Ceiling(RowNumber(Nothing)/2), i.e. make the matrix start a new "table" every 2 repeated columns (rather than 5). This, however, I do not understand, as there is plenty of space for 3 other columns to their right and it is odd and untidy to just put 2!!
I would greatly appreciate any help in this!
Thanks in advance!
Tim
For anybody who is having a similar problem in SSRS 2008, I found the only way to fix this was to set the property named ConsumeContainerWhitespace on the Report itself to true.
In my case the issue was that the matrix on the page was narrow in design mode with a lot of whitespace to the right. When rendered, the matrix was rendered much wider (due to the data) but the renderer would also include the whitespace, causing the report to be much wider than the actual page.
If you set this property, the extra whitespace does not get rendered.
If I understand you correctly I've solved this problem before. The matrix claims extra white space, the solution I used is as follows:
You need to consume the white space.
[-------page width------]
[matrix][-textbox hack-]
I think you can set the textbox to be invisible
Note: When I attempted this in 2005, it only worked when the invisible textbox spanned the entire line.