Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » Documentation / more info
Documentation / more info [message #55014] Mon, 05 October 2020 00:53 Go to next message
jimlef is currently offline  jimlef
Messages: 90
Registered: September 2020
Location: US
Member
I've been digging through the site for info on the QTF/reporting methodologies.

Specifically, I don't see how to set things like Portrait/landscape mode (is that just swapping x/y size values)?
Setting font size/type?
Totals?
Column alignment?

Would love a good overview of the available functions for QTFReport, and similar for more advanced QTF arrangements.

I found the following so far:
https://www.ultimatepp.org/srcdoc$Report$PrintArea_en-us.html
https://www.ultimatepp.org/reference$Reports$en-us.html

And some forum posts from 2011-ish relating to RepGen (which I admit I don't understand Sad )
Re: Documentation / more info [message #55015 is a reply to message #55014] Mon, 05 October 2020 02:05 Go to previous messageGo to next message
jimlef is currently offline  jimlef
Messages: 90
Registered: September 2020
Location: US
Member
I've managed to answer some of my own questions by going to the source... here's some sample code:
	sqlTaxReport.AddColumn(INVOICENUMBER, "Inv NO.", 100);
	sqlTaxReport.AddColumn(DATEPAID, "Date Paid", 200).SetConvert(DateIntConvert());
	sqlTaxReport.AddColumn(CUSTOMERID, "Cust. No.", 65); // OR CUSTNAME, IF NOT ANON
	sqlTaxReport.AddColumn(CUSTNAME, "Customer Name", 140).HeaderTab().Show(false);
	sqlTaxReport.AddColumn(TAXABLESUB, "Taxable", 80).SetConvert(ConvDouble()).SetDisplay(StdRightDisplay()).HeaderTab().AlignRight();
	sqlTaxReport.AddColumn(NONTAXABLESUB, "Non-Taxable", 80).SetConvert(ConvDouble()).SetDisplay(StdRightDisplay()).HeaderTab().AlignRight();
	sqlTaxReport.AddColumn(TAX, "Sales Tax", 80).SetConvert(ConvDouble()).SetDisplay(StdRightDisplay()).HeaderTab().AlignRight();
	sqlTaxReport.AddColumn(GRANDTOTAL, "Total", 80).SetConvert(ConvDouble()).SetDisplay(StdRightDisplay()).HeaderTab().AlignRight();
	sqlTaxReport.AddColumn(COST, "My Parts Cost", 80).SetConvert(ConvDouble()).SetDisplay(StdRightDisplay()).HeaderTab().AlignRight(); // PARTS COST FOR THIS INVOICE
	
.
.
.

void TaxWindow::CreateReport()
{
	if (sqlTaxReport.GetCount() > 0) {
	//  QtfReport(sqlTaxReport.AsQtf());
		Report report;
		report.Landscape().Header("TaxReport");
                report.SetStdFont(SansSerifZ(12));
		report << sqlTaxReport.AsQtf();
		Perform(report);
	}
}


Successfully sets landscape mode, and creates a header that is shown on each page ("TaxReport").

SetStdFont doesn't seem to be doing anything? Of course I'm guessing as to it's field ...

Still looking for a way to set column alignment. (Was hoping sqlArray would send that info through in QTF).
Re: Documentation / more info [message #55017 is a reply to message #55014] Mon, 05 October 2020 06:04 Go to previous messageGo to next message
jimlef is currently offline  jimlef
Messages: 90
Registered: September 2020
Location: US
Member
Well, I have usable reports printing with my test data, I'll attach a sample pdf here.

Still haven't found a way to override font size though LOL

Jim

void TaxWindow::CreateReport(String start, String end)
{
	if ( sqlTaxReport.GetCount() > 0 )
	{
		double sumTaxable = 0.0, sumNontaxable = 0.0, sumTax = 0.0, sumTotal = 0.0, sumParts = 0.0;
		String headertext;
		int strt, ending;
		
		String s = ::Format(Date( 1970, 1, 1) + StrInt(start));
		String e = ::Format(Date( 1970, 1, 1) + StrInt(end));
		headertext << "Tax Report " << s << " to " << e;
		for ( int i = 0; i < sqlTaxReport.GetCount(); i++ )
		{
			sumTaxable += ( double ) sqlTaxReport.Get ( i, TAXABLESUB );
			sumNontaxable += ( double ) sqlTaxReport.Get ( i, NONTAXABLESUB );
			sumTax += ( double ) sqlTaxReport.Get ( i, TAX );
			sumTotal += ( double ) sqlTaxReport.Get ( i, GRANDTOTAL );
			sumParts += (IsNull(sqlTaxReport.Get ( i, COST ))) ? 0.0 : ( double ) sqlTaxReport.Get ( i, COST );
		}

		if (anon.Get() == 1)
			taxQTF = "{{148:297:96:0:119:118:119:119:119 [C2 :: Totals:: :: :: ";
		else taxQTF = "{{135:270:0:189:108:108:108:108:109 [C2 :: Totals:: :: :: ";
		taxQTF << DblStr(sumTaxable) << ":: " << DblStr(sumNontaxable) << ":: " << DblStr(sumTax) <<
			 ":: " << DblStr(sumParts) <<":: " << DblStr(sumTotal) << "}}";
		Report report;
		report.SetStdFont ( SansSerif( 12 ) ); 
		report.Landscape().Header ( headertext ).Footer ( "Page $$P" );
		report << sqlTaxReport.AsQtf() << taxQTF;

		Perform ( report );
	}
}
  • Attachment: taxreport.pdf
    (Size: 35.25KB, Downloaded 116 times)
Re: Documentation / more info [message #55025 is a reply to message #55017] Mon, 05 October 2020 17:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
report << "[8 " << sqlTaxReport.AsQtf() << "]" << taxQTF;

If single digits are too coarse, try

report << "[+20 " << sqlTaxReport.AsQtf() << "]" << taxQTF;
Re: Documentation / more info [message #55026 is a reply to message #55025] Mon, 05 October 2020 17:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
That said, ArrayCtrl::AsQtf is just "toy" function. If I remember well, I never used it for "real" reports... Smile

In my apps, these were usually fetching data from database and formatting them using Qtf.

Mirek

[Updated on: Mon, 05 October 2020 17:26]

Report message to a moderator

Re: Documentation / more info [message #55027 is a reply to message #55017] Mon, 05 October 2020 17:34 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
taxQTF << DblStr(sumTaxable) << ":: " << DblStr(sumNontaxable) << ":: " << DblStr(sumTax) <<
			 ":: " << DblStr(sumParts) <<":: " << DblStr(sumTotal) << "}}";


Should work without DblStr.

taxQTF << sumTaxable << ":: " << sumNontaxable << ":: " << sumTax << ":: " << sumParts << ":: " << sumTotal << "}}";



<< converts everything to text.... (But then you will probably want to convert to two decimal places, so you will need some function there anyway).

Mirek
Re: Documentation / more info [message #55028 is a reply to message #55026] Mon, 05 October 2020 17:43 Go to previous messageGo to next message
jimlef is currently offline  jimlef
Messages: 90
Registered: September 2020
Location: US
Member
Thank you!

Ultimately, as I learn more, I'm going in that direction myself. AsQTF
got me started though, as I could output QTF format files and see what's going on.

For example, your previous suggestion was to output << "[8 " << and a closing "]".
This throws an error in the generated report, extra "]", and font is unchanged -
the generated qtf from as qtf starts with
Quote:

{{153:153:0:215:123:122:123:123:123@L [* #Inv NO.#:: #Date Paid#:: #Cust. No.#:: #Customer Name#:: #Taxable#:: #Non-Taxable#:: #Sales Tax#:: #My Parts Cost#:: #Total#::@W ]


But I think I'm getting the hang of it, as your generated AsQTF and my taxQTF
string shows me the way Smile I can just do a "foreach row" and generate line by
line, even alternating colors...

"[C2 A :: B :: C :: D ::> E ::> F ::> G ::> H ::> I ::@L ]"
"[C2 A :: B :: C :: D ::> E ::> F ::> G ::> H ::> I ::@W ]"

If I'm doing that right...

Jim
Re: Documentation / more info [message #55030 is a reply to message #55027] Mon, 05 October 2020 17:46 Go to previous message
jimlef is currently offline  jimlef
Messages: 90
Registered: September 2020
Location: US
Member
mirek wrote on Mon, 05 October 2020 11:34
taxQTF << DblStr(sumTaxable) << ":: " << DblStr(sumNontaxable) << ":: " << DblStr(sumTax) <<
			 ":: " << DblStr(sumParts) <<":: " << DblStr(sumTotal) << "}}";


Should work without DblStr.

taxQTF << sumTaxable << ":: " << sumNontaxable << ":: " << sumTax << ":: " << sumParts << ":: " << sumTotal << "}}";



<< converts everything to text.... (But then you will probably want to convert to two decimal places, so you will need some function there anyway).

Mirek


I think Format("%2!nl", number) might be what I need Smile but it's good to know about '<<' as I wasn't sure...

I'll try that in my generated QTF and see how it looks.

Jim
Previous Topic: how can i get the image in the RichText?
Next Topic: Report Perform() and printing
Goto Forum:
  


Current Time: Tue Apr 23 11:16:05 CEST 2024

Total time taken to generate the page: 0.02104 seconds