FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Creating table with Trichedit
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Creating table with Trichedit
Posted: Mon Jan 29, 2024 03:14 PM
MMK wrote:Where to lay out or send this file?
Wich file?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Creating table with Trichedit
Posted: Mon Jan 29, 2024 03:41 PM
MMK wrote://You made everything well. Small inaccuracies. There is a working example
#INCLUDE "FiveWin.ch"
#include "richtext.ch"
******************
Function RftDemo()
**********************
Local anchos,j,lFormato:=.F.
//Local Mas_n:={}
local aTable:={}
local nRow,ncol

Local oRtf,aMarca, cOutFile :="Plata.RTF", Sob1
Local aFldNames:= {" Ok ", " 2", " 3", "4","5","6", "7", "8", "9"}

AaDd(aTable,{1,,23,,44,,61,,80} )
AaDd(aTable,{,16,,36,,59,68,,89} )
AaDd(aTable,{,,28,,49,58,,71,84} )

oRTF := SetRT( cOutFile )

NEW PARAGRAPH oRTF TEXT "Sample RTF Output" ;
FONTNUMBER 1 ;
APPEARANCE BOLD_ON+ITALIC_OFF+CAPS_OFF;
FONTSIZE 12 ;
ALIGN CENTER ;
SPACEBEFORE .12 ;
SETDEFAULT

NEW PARAGRAPH oRTF TEXT "" ;
APPEARANCE BOLD_OFF+ITALIC_OFF+CAPS_OFF

SETDATE oRtf FORMAT LONGFORMAT

NEW PARAGRAPH oRTF TEXT "" SETDEFAULT

aMarca=ARRAY(9)
AFILL(aMarca,0)

DEFINE NEWTABLE oRTF ; // Specify the RTF object
ALIGN CENTER ; // Center table horizontally on page
FONTNUMBER 1 ; // Use font #2 for the body rows
FONTSIZE 10 ; // Use 9 Pt. font for the body rows
CELLAPPEAR BOLD_OFF ; // Normal cells unbolded
CELLHALIGN LEFT ; // Text in normal cells aligned left
COLUMNS 9 ; // Table has n Columns
CELLWIDTHS {0.4,0.5,0.5,0.8,0.9,0.9,0.9,0.5,0.5} ; // Array of column widths
ROWHEIGHT .2 ; // Minimum row height is .25"
CELLBORDERS SINGLE ; // Outline cells with thin border
COLSHADE aMarca; // Sombras en columnas
HEADERROWS 1; // dos lineas de titulos
HEADER aFldNames;
HEADERFONTSIZE 10;
HEADERAPPEAR BOLD_ON;
HEADERHALIGN CENTER //;

DEFINE CELL FORMAT oRTF ;
CELLSHADE aMarca
lFormato:=.F.

For nRow= 1 to Len(aTable)
FOR nCol := 1 TO oRTF:nTblColumns
WRITE NEWCELL oRTF TEXT aTable[nRow][nCol] ALIGN CENTER
NEXT
next


END TABLE oRTF
CLOSE RTF oRtf

/*
Go top
Puti:=MSWORD_PATH()
WinExec(puti+" "+ cOutFile)
*/
Return .T.
**************************************
FUNCTION SetRT(cOutFile)
**************************************
LOCAL oRTF
Public oPrinter,aSize

DEFINE RTF oRTF FILE cOutFile ;
FONTS "Times New Roman", "Courier New", "Arial Cyr" ;
FONTFAMILY "froman","fswiss","fmodern";
CHARSET 0,0,10;
FONTSIZE 8 ;
TWIPFACTOR 1440

oRTF:lTrimSpaces := .T.

DEFINE PAGESETUP oRTF MARGINS 0.5,0.5, 0.3, 0.3 ; // ---, ---, сверху,----
ALIGN TOP ;
PAGEWIDTH 8.5 ;
PAGEHEIGHT 11

RETURN oRTF

I did the test with just three rows of aTable but in the application I have to create an RTF file where there are more than one table

for example you can see this figure






using the example created by Anserkk that you find at the beginning of this topic I am forced to create a file for each table, because it makes a mistake, for example if a user has six folders I have to create six tables in a single rtf and not six files different because then I would have difficulty printing them




Your example has problems and I can't compile
Code (fw): Select all Collapse
Progetto: demommk, Ambiente: bcc7Harbor:
[1]:Harbour.Exe demommk.prg  /m /n0 /gc1 /es2 /a /iC:\work\HARBOUR\Include /jC:\work\errori\RICHTE~1\I18n\Main.hil /iinclude;c:\work\fwh\include;C:\work\HARBOUR\include /oObj\demommk.c
Harbour 3.2.0dev (r2008190002)
Copyright (c) 1999-2020, https://harbour.github.io/
Compiling 'demommk.prg'...
demommk.prg(31) Error E0030  Syntax error "syntax error at 'ORTF'"
demommk.prg(53) Error E0030  Syntax error "syntax error at 'NEWTABLE'"
demommk.prg(56) Error E0030  Syntax error "syntax error at 'CELL'"
demommk.prg(61) Error E0030  Syntax error "syntax error at 'NEWCELL'"
demommk.prg(66) Error E0030  Syntax error "syntax error at 'TABLE'"
demommk.prg(86) Error E0030  Syntax error "syntax error at 'RTF'"
demommk.prg(96) Error E0020  Incomplete statement or unbalanced delimiters
demommk.prg(98) Error E0030  Syntax error "syntax error at '11'"
demommk.prg(99) Error E0030  Syntax error "syntax error at 'JAN'"
9 errors

No code generated.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 16
Joined: Thu Jan 22, 2009 06:24 AM
Re: Creating table with Trichedit
Posted: Mon Jan 29, 2024 04:53 PM
Let's begin with the last question
1. Mistakes
You have an old version of richtext

2. single rtf and six files
The END TABLE oRTF team closes the table, but does not close the file.
Therefore you just continue to fill out the file
If it is necessary - oRtf:NewPage(), and -
NEW PARAGRAPH oRTF TEXT....
..........................
DEFINE NEWTABLE oRTF;...
..............
END TABLE oRTF
............
And so all tables.
The CLOSE RTF oRtf team closes the file

3.Wich file?
Fresher version of richtext :)
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Creating table with Trichedit
Posted: Mon Jan 29, 2024 05:01 PM
MMK wrote:Let's begin with the last question
1. Mistakes
You have an old version of richtext

2. single rtf and six files
The END TABLE oRTF team closes the table, but does not close the file.
Therefore you just continue to fill out the file
If it is necessary - oRtf:NewPage(), and -
NEW PARAGRAPH oRTF TEXT....
..........................
DEFINE NEWTABLE oRTF;...
..............
END TABLE oRTF
............
And so all tables.
The CLOSE RTF oRtf team closes the file

3.Wich file?
Fresher version of richtext :)
Can you send the new classe at silvio[dot] Falconi [at]gmail[dot]com thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion