Шаблон документов. Формат FlexCelReport

по сравнению с
Текущая Шевнин Игнат
на мар 07, 2013 11:47.

Ключ
Эта строка удалена.
Это слово было удалено. Это слово было добавлено.
Эта строка добавлена.

Изменения (10)

просмотр истории страницы
Now you have to write:
# All the titles, images and formatting of the report. You can include graphs, filters, conditional format, images or anything you can think of. You can also fill as many sheets as you want, all of them will be filled with the data you request.
# The fields to be filled from the database. Here you have to put a text on the form *\##<dataset>##<field>*For \*##<dataset>##<field>*For example if you are going to create a dataset called "Cust" with a field "Country" you will write ##Cust##Country in the cell where you want the value.

Note that the database can be a "Real" one or a TFlxMemDB holding memory data.
# You can define some extra variables in the datamodule that are not tied to the database, by writing *\#.<Variable>*. For example, if you had defined a published variant property called "Current_Date" you could include its value by writing #.Current_Date in a cell
# You can also include variant arrays here, just write *\#.<Variable>#.<index1>#.<index2>#. \*#.<Variable>#.<index1>#.<index2>#. …… #.<indexN>*For example, to write the value of the published variant property Price\[1,3\] into a cell, you could write something like "#.Price#.1#.3

\\
But you can't replace more than one value in the same cell. For example, if you have in A1: ##Client##FirstName ##Client##LastName, this will not be replaced correctly. To solve this case, you need to create a new calculated field in the dataset that contains the two others concatenated, and use this field in the template.
\\
*Note*: from v2.1, you can also use the [Values\|_property_Values:_TFlxPropList;|] [Values&#124;_property_Values:_TFlxPropList;\||] property instead of defining a published prop.
\\
Another thing to take in count, date and time fields. They will be passed as a number to Excel (there is no variant to represent a date/time). So you *must* format the cell including the date (for example ##Client##SaleDate) with a *date* format. Note that when programming the component I've tried to pass Field.value to this cells (it passes a string), and it works without needing to format, but has problems with international representations.
Besides cells, you can also stream Images (only in native mode) or comments to the file. For comments, just write the usual ##Dataset##Field in the comment.
For images, drop a Blank image, select it, and in the names combo, change its name to ##DataSet##Field##ImageType
\\ !worddav8e34d6dddfd505df0e87078eac40a887.png|height=133,width=199!\\
where ImageType is JPEG or PNG. Verify that the image format in the database is one of them, or convert them as needed. For more info, see the demo app.
\\


h4. *This range will be copied once for each entry of the Dataset, with the values replaced. It is possible to create as many ranges as you want inside others, to reflect master-detail relationships. (For example, you may have the _*{*}{_}Cust{_}{*}*_ range the* *Cust* *range covering all used range of the sheet, and then a _*{*}{_}Orders{_}{*}*_ range a* *Orders* *range inside and a _*{*}{_}Items{_}{*}*_ inside the _*{*}{_}Orders{_}{*}*_* a* *Items* *inside the* *Orders*

\\
A problem that happens with Excel and that I have not been able to completely solve is related with the way you insert the cells.
Imagine you define the following Template:
\\ !worddava953eff3013a84a87904aa11887f8e9c.png|height=128,width=260!\\
And let be the __Items__ range = A2:B2
\\
When the report is run it will insert n-1 cells between rows 2 and 3, where n is the number of records in the Items dataset. But the formula in B3 ( "=Sum(B2:B2)" ) will not change to reflect the inserted rows. You will get something like this:
\\ !worddav26365b10e0fcef247fe551b28211b470.png|height=128,width=260!\\
As a rule of thumb, to solve this problem you should *always leave a blank line* below the ranges to let the formulas adapt. You should define a template like:
\\ !worddav1297e2fd0b91c692549b37f406d762b2.png|height=128,width=260!\\
With the __Items__ range defined as A2:B2. Now, when the rows are inserted between rows 2 and 3, the formula now in B4 will be updated right.
\\
You can leave the template this way (by making the row 3 very small), or if you want to get rid of the blank line, you could use the "...delete row...", as in the image.
\\ !worddav5fff02071dd877a4657e34923f522c6d.png|height=128,width=260!\\
All the rows that have in the "A" column the text "…delete row…" (without any spaces an all in lowercase) will be deleted after the report is run. An use of this is if you want to create a Pivot Table or a Graph , and you can see it in the PivotDemo.xls template.
\\
* For reports in general, be sure to use a 'snapshot' or similar transaction mode, or the data may be changed between the first record that goes to Excel and the last.
* When running the demo, you might end up with some files \*.mb. These are temporary files from the BDE, not from the component\!\!\! (The component doesn't create any temporary file)
* *Always* define a *_*{*}{_}MAIN{_}{*}*_* *MAIN* range \! See \[Range{anchor:_Hlt4381590} notes\|#_Notes\]
* When you don't know which command or parameter to use, record a macro in Excel and see what it does. And don't forget you have the help on Visual Basic for Excel also.
* In native mode, when you use formulas, Excel will ask for saving a Worksheet saved with an earlier version. This really means that it will save the worksheet with the formulas recalculated. The only way to avoid this message is not to use formulas.