CN101334730B - Report printing method - Google Patents

Report printing method Download PDF

Info

Publication number
CN101334730B
CN101334730B CN2008101416396A CN200810141639A CN101334730B CN 101334730 B CN101334730 B CN 101334730B CN 2008101416396 A CN2008101416396 A CN 2008101416396A CN 200810141639 A CN200810141639 A CN 200810141639A CN 101334730 B CN101334730 B CN 101334730B
Authority
CN
China
Prior art keywords
type face
type
row
height
page
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN2008101416396A
Other languages
Chinese (zh)
Other versions
CN101334730A (en
Inventor
喻金石
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CN2008101416396A priority Critical patent/CN101334730B/en
Publication of CN101334730A publication Critical patent/CN101334730A/en
Application granted granted Critical
Publication of CN101334730B publication Critical patent/CN101334730B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a report printing method, comprising the following steps of: (1) extracting relevant data information from a table to be printed; (2) generating a blank print page, calculating the coordinate position of the page head and the page foot of the table to be printed in the print page and setting the information of the page head and the page foot at the corresponding position in the print page; (3) generating an initial grid in the print page according to the default line-height, the size of the print page and the proportion of the row number and row width of the table to be printed; (4) adjusting the height of each line in the grid according to the table data of the table to be printed and setting the corresponding data into the grid; and (5) drawing the generated print page and carrying out print preview and printing. The adoption of the invention can generate the page of print preview intelligently according to a java table and carry out printing, meets the need of users for the printing of a common report table, has stronger practicability and is easy to realize.

Description

A kind of report printing method
Technical field
The present invention relates to a kind of report printing method.
Background technology
In network management system, report printing is a kind of important way of report messages output.In present report printing method, generally the form, data of form, numerous attribute informations are described by the report customization template, produce printer page by template then.The process of custom built forms is loaded down with trivial details and make mistakes easily, uses template to solidify pattern and the form printed simultaneously, can not satisfy the demand of user to the report printing What You See Is What You Get.
Summary of the invention
Technical matters to be solved by this invention provides a kind of more general report printing method,
Has stronger practicality.
For solving the problems of the technologies described above, the present invention is achieved by the following technical solutions:
A kind of report printing method may further comprise the steps:
(1) from treat type list, extracts related data information;
(2) generate empty type face, calculate top margin, the coordinate position of footer in type face for the treatment of type list, the relevant position is provided with top margin and footer information in type face again;
(3) according to default row height, printer page the size and treat that the tabular number of type list and col width ratio generate initial grid in type face;
(4) adjust each height of going in the described grid according to the list data for the treatment of type list, and to corresponding data wherein is set;
(5) draw the type face that is generated, print preview and printing.
Wherein, described step (4) also comprises afterwards: if finish using or no longer be fit to be provided with newline by the remaining space that calculates current type face in the space of current type face, then delete the row that data are not set in the current type face, and generate next type face, generating mesh therein, data are set in that this mesh relay is continuous, have been generated to type face until the total data for the treatment of type list.
Wherein, described data message comprise form page header, footer information, tabular number, tabular is wide and list data.
Wherein, in the described step (2), but according to the drawing area of type face, rendered fonts type, alignment thereof and the character quantity that needs to draw calculate the coordinate position of top margin and footer.
Wherein, described step (3) further comprises:
But 1. calculate type face residue height in hand according to the high of type face drawing area and the top margin that has taken up room and the height of footer;
2. calculate the line number that tentatively can be provided with in the type face according to described type face residue height in hand and default line height, the width of each row when in type face, same number of columns being set according to the columns for the treatment of type list and the calculating of col width ratio simultaneously;
3. the width according to each row in the described line number that tentatively can be provided with, the columns for the treatment of type list and the type face generates initial grid.
Wherein, in the described step (4), the method of adjustment of each line height is in the described grid: for each row, according to col width, rendered fonts type, alignment thereof and the character quantity that needs to draw calculate the height that each cell needs of this row are provided with, get that wherein maximal value is high as the row of this row.
The present invention has following beneficial effect:
Adopt the present invention, can generate the page of Print Preview intelligently and print according to the java form, satisfied the demand that the user prints general form form, practicality be stronger, and is easy to realize.
Description of drawings
Fig. 1 is a method flow diagram of the present invention;
Fig. 2 is a type face of using the common form of the inventive method generation;
Fig. 3 is the type face of form of cell of having used merging that the inventive method generates;
Fig. 4 is a type face of using the tree-like form of the inventive method generation.
Embodiment
See also Fig. 1, this figure is depicted as report printing method flow process of the present invention, is specially:
101, adopt the javax.swing.JTable control from treat type list, to extract related data information, comprise page header, footer information, the tabular number for the treatment of type list, tabular is wide and list data, page header wherein comprises heading message and table descriptor two parts.
102, the size and Orientation of printer page is set, default line height.The printer page size generally can be set to A4 paper (842pixel, 595pixel) size, but also be page drawing area; To the Y-axis positive dirction, front-right was to being the X-axis positive dirction under the direction of printer page generally can be provided with.
103, generate empty type face, first afterwards accounting report top margin, the coordinate position of footer in type face, the top margin position comprises that X, Y coordinate and the table of the title for the treatment of type list describe the X of information, Y coordinate; The relevant position is provided with top margin and footer information in type face again.
104, according to the residue height in hand of default row height, printer page and treat that the tabular number of type list and col width ratio generate initial grid in type face.
105, adjust the height of each row in the described grid according to the list data for the treatment of type list, and to corresponding data wherein is set.
106, draw the type face that is generated, print preview and printing.
The present invention is described in further detail below in conjunction with drawings and the specific embodiments:
Below with modal A4 paper (842pixel 595pixel) prints to example, introduces report printing method of the present invention in detail:
The first step: the coordinate position of accounting report top margin, footer;
Need consider in conjunction with following factors is whole during the coordinate position of accounting report top margin, footer:
But drawing area: the size according to paper is provided with, the general use width that only needs;
Rendered fonts: the height and the width that need obtain this font character late;
Alignment thereof: comprise left-justify, Right Aligns, align center;
The quantity of draw characters: need line feed under the character situation how.
Second step: generate initial grid in type face, generating algorithm is as follows,
B1, calculate the residue height in hand H of type face, but calculate according to the height of the height-footer of the height-top margin of formula H=drawing area;
B2, calculate the line number that tentatively can be provided with in the type face according to residue height in hand H and default row height (being defaulted as 21pixel).
B3, according to the width (595pixel) of A4 paper, calculate width of each row when in type face, same number of columns being set according to the columns for the treatment of type list and col width ratio; Width according to each row in the described line number that tentatively can be provided with, the columns for the treatment of type list and the type face generates initial grid afterwards.
The 3rd step: it is high to adjust the row that each is gone in the above-mentioned grid according to the list data for the treatment of type list, and to corresponding data wherein is set.If finish using or no longer be fit to be provided with newline by the remaining space that calculates current type face in the space of current type face, then delete the row that data are not set in the current type face, and generate next type face, generating mesh therein, data are set in that this mesh relay is continuous, have been generated to type face until the total data for the treatment of type list.In this step, the method for adjustment that each every trade is high in the grid is: for each row,
C1, calculate the height of this each cell of row, need to consider in conjunction with following factors is whole:
This row col width: the proportional convergent-divergent of form grid column width, all row can be shown in a type face, just obtain the width of each row;
Rendered fonts: the height and the width that need obtain this font character late;
Alignment thereof: comprise left-justify, Right Aligns, align center;
Cell content: need line feed under the character situation how.
C2, needs are striden page or leaf cell processing and row is high calculates: if the grid of type face has been provided with data line, and the height that cell needs is greater than the residue height in hand, then, directly enter into the generation of next type face not in the content of current type face Cell display; If the grid of type face is not provided with data line, and the height that cell needs is greater than the residue height in hand of type face, then need be in this form page or leaf Cell display part content, the residue height in hand H of report printing this moment page or leaf is promptly high as the row at current type face that this cell needs, and preserve not display part, in the next type face that generates, show.
C3, get the maximal value of each required capable senior middle school of cell as this every trade height.
The 4th step: use JDK API to draw the type face that generates, for Print Preview and printer prints,
The top margin and the footer of d1, drafting report printing page or leaf;
The grid and the grid data of d2, drafting type face, the specific implementation method is as follows:
At first draw the housing of type face, form the type face grid by drawing horizontal line and vertical line then.Then in the type face grid, draw the character for the treatment of type list, form the type face data grids.Wherein the drafting of horizontal line is high based on the row of each row in the type face grid, and the drafting of vertical line is used the renderer of JTextArea as each grid based on the col width of each row in the type face grid when draw characters, so that the folding row;
The preview and the printing function of d3, realization type face.
See also Fig. 2 to Fig. 4, be respectively shown in these figure and adopt the common form that said method generated, the form of Merge Cells and the type face of tree table.
Above embodiment is only unrestricted in order to technical scheme of the present invention to be described, only with reference to preferred embodiment the present invention is had been described in detail.Those of ordinary skill in the art should be appreciated that and can make amendment or be equal to replacement technical scheme of the present invention, and do not break away from the spirit and scope of technical solution of the present invention, all should be encompassed in the middle of the claim scope of the present invention.

Claims (4)

1. a report printing method is characterized in that, may further comprise the steps:
(1) from treat type list, extracts related data information;
(2) generate empty type face, calculate top margin, the coordinate position of footer in type face for the treatment of type list, the relevant position is provided with top margin and footer information in type face again;
(3) according to default row height, printer page the size and treat that the tabular number of type list and col width ratio generate initial grid in type face;
(4) adjust each height of going in the described grid according to the list data for the treatment of type list, and to corresponding data wherein is set;
(5) draw the type face that is generated, print preview and printing;
In the described step (2), but according to the drawing area of type face, rendered fonts type, alignment thereof and the character quantity that needs to draw calculate the coordinate position of top margin and footer;
In the described step (4), the method of adjustment of each line height is in the described grid: for each row, according to col width, rendered fonts type, alignment thereof and the character quantity that needs to draw calculate the height that each cell needs of this row are provided with, get that wherein maximal value is high as the row of this row.
2. report printing method as claimed in claim 1, it is characterized in that, described step (4) afterwards, step (5) also comprises before: if finish using or no longer be fit to be provided with newline by the remaining space that calculates current type face in the space of current type face, then delete the row that data are not set in the current type face, and generate next type face, generating mesh therein is provided with data in that this mesh relay is continuous, has been generated to type face until the total data for the treatment of type list.
3. report printing method as claimed in claim 1 or 2 is characterized in that, described data message comprise form page header, footer information, tabular number, tabular is wide and list data.
4. report printing method as claimed in claim 3 is characterized in that, described step (3) further comprises:
But 1. calculate type face residue height in hand according to the high of type face drawing area and the top margin that has taken up room and the height of footer;
2. calculate the line number that tentatively can be provided with in the type face according to described type face residue height in hand and default line height, the width of each row when in type face, same number of columns being set according to the columns for the treatment of type list and the calculating of col width ratio simultaneously;
3. the width according to each row in the described line number that tentatively can be provided with, the columns for the treatment of type list and the type face generates initial grid.
CN2008101416396A 2008-07-18 2008-07-18 Report printing method Expired - Fee Related CN101334730B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2008101416396A CN101334730B (en) 2008-07-18 2008-07-18 Report printing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2008101416396A CN101334730B (en) 2008-07-18 2008-07-18 Report printing method

Publications (2)

Publication Number Publication Date
CN101334730A CN101334730A (en) 2008-12-31
CN101334730B true CN101334730B (en) 2011-05-11

Family

ID=40197346

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2008101416396A Expired - Fee Related CN101334730B (en) 2008-07-18 2008-07-18 Report printing method

Country Status (1)

Country Link
CN (1) CN101334730B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101770348B (en) * 2009-12-29 2012-07-25 用友软件股份有限公司 Printing method and printing device
US20110276868A1 (en) * 2010-05-05 2011-11-10 Microsoft Corporation Multi-Threaded Adjustment of Column Widths or Row Heights
CN102799398B (en) * 2012-06-27 2016-03-30 用友优普信息技术有限公司 Table body device for zooming and table body Zoom method
CN103617012B (en) * 2013-12-05 2016-08-17 用友网络科技股份有限公司 Report printing method
CN104228368B (en) * 2014-07-31 2018-08-31 东莞市福欣电脑科技有限公司 A kind of method of continuous not print page under WINDOWS systems
CN104714766B (en) * 2015-03-12 2017-11-03 福建工程学院 A kind of method directly printed in WEB forms browser
CN106802778A (en) * 2017-02-15 2017-06-06 路新喜 A kind of Intelligent printing method and system
CN108804405A (en) * 2018-06-12 2018-11-13 和宇健康科技股份有限公司 The cross-page method of text table of ScaleRichView editing machines
CN111045614B (en) * 2019-12-12 2023-07-21 中国建设银行股份有限公司 Method for printing running water report, method for generating overprint file, client and server

Also Published As

Publication number Publication date
CN101334730A (en) 2008-12-31

Similar Documents

Publication Publication Date Title
CN101334730B (en) Report printing method
CN101876967B (en) Method for generating PDF text paragraphs
CN101968783B (en) Method and device of converting XML document into Excel document
CN102722475A (en) Method for converting form in portable document format (PDF) document into Excel form
CN100552671C (en) A kind of implementation method of pre-typesetting and system
CN109857670B (en) Test report automatic generation method based on universal template
CN101976232A (en) Method for identifying data form in document and device thereof
CN1828580B (en) Rectangular array words frame layout method for fitting word content
CN105511818B (en) The generation method of voucher templates, apparatus and system
CN103778732A (en) Electronic-invoice issuing method and device
TW200830207A (en) Business form creating system, network system using the same, and business form creating method
CN103617012B (en) Report printing method
JP7103495B2 (en) Print data processing equipment, printing system and printing data processing method
CN102799398B (en) Table body device for zooming and table body Zoom method
CN103914933A (en) Invoice printing method and apparatus based on XML technology
JP2004295523A (en) Bar code image generator and program
CN101436307A (en) Interactive typesetting method and system for formula
CN100480894C (en) Printing method with small margin or no margin
CN102214177B (en) Method and device for vertically typesetting characters in label
CN101207742A (en) Method and device for paging of display contents and digital television receiving device
CN102158825A (en) Handwritten multimedia message realization method
CN102467353B (en) Document printing method and computer
CN106598510B (en) The method and device of compatible two kinds of printing types
CN103617014A (en) Method for printing home pages and continuation pages of statements
CN110077138A (en) Polymorphic jet printing method for high parsing ink jet numbering machine

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20110511

Termination date: 20190718

CF01 Termination of patent right due to non-payment of annual fee