Two self-contained columns in reportlab pdf - multiple-columns

I am reading the reportlab doc to try generate two columns in a canvas page, but those columns I want to be self-contained
example.
When I do something like this:
doc = BaseDocTemplate("example.pdf")
frame1 = Frame(doc.leftMargin, doc.bottomMargin, doc.width/2-6, doc.height, id='col1')
frame2 = Frame(doc.leftMargin+doc.width/2+6, doc.bottomMargin, doc.width/2-6, doc.height, id='col2')
doc.addPageTemplates(
[PageTemplate(id='First',frames=[frame1,frame2], onPage=partial(footer,content=footer_content),pagesize=doc.pagesize),
])
doc.build(Story)
I got two colums, cause I adding a list of frames, but I dont want the content flating from one frame to another.
With this example I got this.
col1 col2
aaaaa ccddd
aaabb ddeee
bbccc fffgg
How you can see the content is floeating, but what I want is to be self-contained, example
colum1 column2
aaaaa hereothercontent
bbbbb put numbers
11122 tables
whatever whatever
Any Idea how to make my frames self-contained?

Related

Is it possible to dynamically add (check-marked) rows to another tab/sheet? Google Sheet

Quick Brief
I have a sheet with 3 tabs (Overview, Book 1, Book 2). The first tab (Overview) contains a lot of rows (Programs) with a lot of columns (information). I want to dynamically add these rows (Programs) to another tab (Book) whenever I checkmark them for that location, if possible!. To give you a visual idea:
Tab: Overview
Tab: Book 1
Tab: Book 2
Current solution
My current solution, for now, is making filters for every Book-name containing an 'x' and sort the programs alphabetically, and just copy-paste them to that given tab (book-location). However, this example above is just a tiny fraction of my actual document. I have over 300 programs and over 20 different books which have to be updated every-time I add or delete a program, which is time-consuming. Again, I'm not sure if the above is possible or if it needs another setup to achieve the same. Any idea/solution would be much grateful!
You can use the query function to achieve this:
For example put formula in Book 1 Cell A1 :
=QUERY({Overview!A1:H},"Select * where Col7 ='x' ")
Similarly in Book2 Cell A1
=QUERY({Overview!A1:H},"Select * where Col8 ='x' ")

Example to combine headers footers paragraphs of html and Tables

jspdf-autotable examples['header-footer'] example gets me most of what I need for my task.
I am trying to add rich text (constant font some bold and under line words) before and after a table. looking at examples.content did not make it clear.
So a complete PDF might be:
1. some paragraphs of text
2. a table on more than one page
3. some paragraphs of text
4. another table on more than one page
how do I combine all of this in one var doc = new jsPDF(); ?
Example code would be very appreciated.
The key is to use doc.autoTable.previous.finalY to get the final y position where the table ended drawing. You can than dynamically use that to draw text with doc.text(). If you want further guidence, please update your question with more info on what you have tried and what didn't work.

SSRS Matrix header repeat on each page (but outside of group to show every header from ds?)

I have a Matrix which I am trying to get a specific header to repeat on each page. To keep it simple it looks something like this:
| | Months |
|Division| |
| Name | Sales |
--- new page for each division ---
If I include the [Month] columns inside the Division group, it only shows the [Months] that have activity for that [Division]. For each page (per [Division]) I want to show all active [Months] within the dataset, not just that particular [Division].
So I tried creating a new row above, OUTSIDE of the [Division] group. This worked great for the first page, but I cannot get it to repeat on each page.
Is there a way to somehow set a Matrix row as a header for each instance/page of that tablix in the report?
Or
Show every [Month] from the dataset, inside of the [Division] group, and not just the active [Months] inside the [Division]?
Hopefully that makes sense, if not I will try my hardest to explain better.
Thanks in advance!!
I found the answer here:
https://msdn.microsoft.com/en-us/library/dd207045.aspx
Under "To Display a static row or column on multiple pages"
Thanks

Get tabledata from html, JSOUP

What is the best way to extract data from a table from an url?
In short I need to get the actual data from the these 2 tables at: http://www.oddsportal.com/sure-bets/
In this example the data would be "Paddy power" and "3.50"
See this image:
(Sorry for posting image like this, but I still need reputation, i will edit later)
http://img837.imageshack.us/img837/3219/odds2.png
I have tried with Jsoup, but i dont know if this is the best way?
And I can't seem to navigate correctly down the tables, I have tried things like this:
tables = doc.getElementsByAttributeValueStarting("class", "center");
link = doc.select("div#col-content > title").first();
String text1 = doc.select("div.odd").text();
The tables thing seem to get some data, but doesn't include the text in the table
Sorry, man. The second field you want to retrieve is filled by JavaScript. Jsoup does not execute JavaScript.
To select title of first row you can use:
Document doc = Jsoup.connect("http://www.oddsportal.com/sure-bets/").get();
Elements tables = doc.select("table.table-main").select("tr:eq(2)").select("td:eq(2)");
System.out.println(tables.select("a").attr("title"));
Chain selects used for visualization.

SSRS - How to build a simple multi-column report?

I am using SQL Server 2008 and I want to show 1 single field from a table in multiple columns in the report. Just like if I were to print labels. How can I achieve this?
Example:
Instead of printing:
Names Report
Andrea
Austin
Barbara
Bob
Bruno
Cathy
Chis
...
I want to print in columns (say 3 fixed columns):
Names Report
Andrea ---- Bruno ---- Darren
Austin ---- Cathy ---- Francis
Barbara ---- Chis ---- Gabriel
Bob ---- David ---- Gerald
....... ---- ....... ---- .......
Edit: If I run the report and click on "Print Layout" button, I can see multiple columns. Can I set this mode as default?
For Horizontal layout of labels...
One choice is to use the columns property on the report or body elements.
This doesn't always display correctly On reportviewer. I've noticed that even if it displays correctly on your IDE and when you export to PDF. In the report viewer it will display only one column. Also it snakes the labels top to bottom then left to right.
One choice is to use a matrix and group on every 3 rows (if you want 3 columns).
This one is a little complicated.
My solution of choice is to put 3 vertical lists on the page. put the same label in each list. Return the row number in your dataset. Then just filter each list on modulo 3
For example
Result set
RIndex Fname
1 abe
2 burt
3 fred
4 george
Filter expressions
list 1 -> =Fields!RIndex.Value mod 3 = =1
list 2 -> =Fields!RIndex.Value mod 3 = =2
list 3 -> =Fields!RIndex.Value mod 3 = =0
Result
Abe Burt Fred
George
The method I use is a bit similar as what Vern suggested but differs enough to make it worth mentioning here.
You can combine the ROW_NUMBER with the modulo (%) operator directly in the query to fabricate the column number in which the record should get displayed. Here's an example that generates one while taking a group into account:
declare #numberOfColumns int = 4;
select dpc.EnglishProductCategoryName, dp.ProductAlternateKey
, (ROW_NUMBER() OVER (
PARTITION BY dpc.EnglishProductCategoryName
ORDER BY dp.ProductAlternateKey) + #numberOfColumns - 1) % #numberOfColumns + 1
as DisplayColumn
from dbo.DimProduct dp
inner join dbo.DimProductSubcategory dps on dps.ProductSubcategoryKey = dp.ProductSubcategoryKey
inner join dbo.DimProductCategory dpc on dpc.ProductCategoryKey = dps.ProductCategoryKey;
To get this displayed I'm using nested tables which are then filtered on DisplayColumn.
Have a read through following article for all the details: Creating Multiple-Column Reports
Use the 'Report' menu in Visual Studio and select 'Report Properties'. You can set columns in the 'Layout' tab.
Try this msdn article about newsletter-style reports for more details: http://msdn.microsoft.com/en-us/library/ms159107.aspx
This method does have a limitation though so in some cases it might not be applicable:
Only PDF and Image renderers support
newsletter-style reports.
EDIT:
So one approach is to use multiple tablix with a filter that checks RowNumber and accordingly displays particular records in each table.
The other way is called Newsletter-style report (link). This formatting is retained only when report is exported as PDF or Image. It can be previewed only when you select 'Print Layout' on the Preview tab in Visual Studio. Here is an example:
Create a new report with the foll. dataset: SELECT ID,NAME FROM TABLENAME
Add a new table to the report and select the ID and Name as columns
Click on the tablix and press F4 to edit the tablix properties. In the properties window, change the Size - set the width to 2in
Click on the report area outside the report page boundary and press F4 to edit the report properties. In the properties window, change the Column value to 3, and column spacing value to 0.1
On the report scroll to the right hand side, you will notice that there are 2 new columns (so totally 3 columns on the report - because you selected 3 in step 4 above). Now click on the margin at the start of the column 2 and pull it further to the left to bring it as close to the column 1. This is only to reduce the need for huge page size.
Right click on the report area outside the report page boundary and select Report Properties. Change the Page Size - Set the width to 10in
Preview the report. Now select the 'Print Layout' tab to see the result. This formatting is retained only when report is exported as PDF or Image.
As noted in points 5 and 6 - since the report body flows into multiple columns, you must ensure that the page size is at-least equal to -> ([Original report body size times the number of columns] + all the column spacing values). Otherwise it will look messy.