The storekeeper needs to upload a list of all items that are not marked for deletion. Fields for upload:

  1. Name.
  2. Vendor code.
  3. Type of nomenclature.
  4. Item type.

This is what the Excel table will look like after uploading:

Let's consider two solutions: without programming and with the participation of a programmer.

Programming

To upload the item to an XLS file, we will create a query to the database to obtain the item and place the result in tabular part unloading processing. Here is the processing form:

By clicking on the "Fill" button, the tabular part "Unloading Data" of the processing is filled in, with the corresponding details added. The handler for this button has the following code:

Procedure ButtonExecutePress(Button) Request = New Request; Request. Text = " SELECT | Nomenclature. Link AS Nomenclature, | Nomenclature. Vendor code, | Nomenclature. Type of Nomenclature, | Nomenclature. Type of Nomenclature. Nomenclature Type AS Nomenclature Type |FROM| Directory . Nomenclature AS Nomenclature|WHERE | NOT Nomenclature. FlagDeletion | AND NOT Nomenclature. This group" ; DataTable = Query. Execute () . Unload() ; Upload Data. Load(DataTable) ; EndProcedure

Everything should be clear here. The fun begins when you click on the “Save” button. First, the dialog for selecting the path to save the XLS table is called up. Then, using the data in the tabular part of the processing, a tabular document is filled in according to the previously created layout. The layout added to the processing is as follows:

Procedure BasicActionsFormsAction(Button) // Call the file selection dialog to save the XLS table Mode = FileSelectionDialogMode. Preservation; OpenFileDialog = NewFileSelectDialog(Mode); OpenFile Dialog. FullFileName = " " ; OpenFile Dialog. MultipleSelect = False ; Text = "ru = " "XLS Table" " ; en =" " XLS table " " " ; Filter = NStr(Text) + " (* . xls) |* . xls" ; Open File Dialog. Filter = Filter; Open File Dialog. Title = " Select save path" ; If FileOpenDialog. Select() Then FilePath = FileOpenDialog.FullFileName; Otherwise Text = " No save path has been selected!" ; Warning(Text) ; Return ; EndIf ; // Create a spreadsheet document TableSave = New TableDocument; // Get the padding layout and layout areas Layout = ThisObject. GetLayout(" Unloading table" ); AreaHeader = Layout. GetArea(" Header "); AreaString = Layout. GetArea(" Line" ) ; // Output data to a spreadsheet document TableSave. Output(AreaHead) ; For Each Page From DataUpload Loop FillPropertyValues(AreaString.Parameters, Page); TableSave. Output(AreaString) ; EndCycle ; // Save the spreadsheet document to disk TableSave. Write(FilePath, TabularDocumentFileType. XLS) ; End of Procedure

After saving, there will be an Excel spreadsheet file on the disk with a list of uploaded items. You could see an example file at the beginning of the article.

The user can

In fact, a programmer is not necessary for such a task. The user can do everything himself without any tricks.

For example, by going to the item list and running the command "All actions" -> "Show list" from the list of items, the user will receive a list of items in the generated spreadsheet document.

After the spreadsheet document has been generated, by clicking on the "Save" button or through the "File->Save" menu, the user can write the spreadsheet document to XLS file specifying its name and destination directory.

That's all! No processing is required for unloading. Of course, if you have a fairly simple case of downloading data.

Is it that simple?

It's really simple, you don't need to connect any external components. In addition, we can upload in this way not only to files in the format Excel tables, but also other formats supported by the platform.

You can process the example from the article download from link.

In order to account for money and goods, various tables are widely used in business. Almost every document is a table.

One table lists the goods to be shipped from the warehouse. Another table shows the obligations to pay for these goods.

Therefore, in 1C, working with tables occupies a prominent place.

Tables in 1C are also called “tabular parts”. Directories, documents and others have them.

The query, when executed, returns a table that can be accessed in two different ways.

The first - faster - selection, obtaining rows from it is possible only in order. The second is uploading the query result into a table of values ​​and then random access to it.

//Option 1 – sequential access to query results

//get the table
Select = Query.Run().Select();
// we go through all the lines of the query result in order
While Select.Next() Loop
Report(Selection.Name);
EndCycle;

//Option 2 – uploading to a table of values
Request = New Request("SELECT Name FROM Directory.Nomenclature");
//get the table
Table = Query.Run().Unload().
//further we can also iterate through all the lines
For each Row from Table Cycle
Report(String.Name);
EndCycle;
//or arbitrarily access strings
Row = Table.Find("Shovel", "Name");

An important feature is that in the table that is obtained from the query result, all columns will be strictly typed. This means that by requesting the Name field from the Nomenclature directory, you will receive a column of the String type with an allowable length of no more than N characters.

Table on the form (thick client)

The user works with the table when it is placed on the form.

We discussed the basic principles of working with forms in the lesson on and in the lesson on

So, let's place the table on the form. To do this, you can drag the table from the Controls panel. Similarly, you can select Form/Insert Control from the menu.

The data can be stored in the configuration - then you need to select the existing (previously added) tabular part of the configuration object whose form you are editing.

Click the "..." button in the Data property. In order to see the list of tabular parts, you need to expand the Object branch.

When you select the tabular part, 1C itself will add columns to the table on the form. Rows entered by the user into such a table will be saved automatically along with the reference book/document.

In the same Data property, you can enter an arbitrary name and select the Value Table type.

This means that an arbitrary table of values ​​has been selected. It will not automatically add columns, nor will it be automatically saved, but you can do whatever you want with it.

Clicking right click on the table you can add a column. In the properties of a column, you can specify its name (for reference in 1C code), the column heading on the form, the connection with the attribute of the tabular part (the latter - if not an arbitrary table is selected, but a tabular part).

In the table properties on the form, you can specify whether the user can add/delete rows. A more advanced form is the View Only checkbox. These properties are convenient to use for organizing tables intended for displaying information, but not editing.

To manage the table, you need to display a command panel on the form. Select the menu item Form/Insert Control/Command Bar.

In the command bar properties, select the Autofill checkbox so that the buttons on the panel appear automatically.

Table on form (thin/managed client)

On in a manageable form These steps look a little different. If you need to place a tabular part on the form, expand the Object branch and drag one of the tabular parts to the left. That's all!

If you need to place a table of values, add a new form attribute and in its properties specify the type – table of values.

To add columns, use the right-click menu on this form attribute, select Add attribute column.

Then also drag the table to the left.

In order for a table to have a command bar, in the table properties, select the values ​​in the Usage – Command bar position section.

Uploading a table to Excel

Any 1C table located on the form can be printed or uploaded to Excel.

To do this, right-click on an empty space in the table and select List.

In a managed (thin) client, similar actions can be performed using the menu item All actions/Display list.

A value table is a specific universal object designed to store data in a tabular representation. Key Difference tables from application objects - this means there is no binding to physical database tables. The value table exists only in random access memory, which, on the one hand, provides unique opportunities, and on the other, imposes certain restrictions. Nevertheless, the possibilities of interaction with the table are comparable to interaction with objects that actually exist in the database.

Historically, the table of values ​​in 1C has a dual purpose, being a virtual analogue of existing tables, but at the same time it is also a control element. With the move to a managed application, much of this functionality has been deprecated, but it can now also be a user interface element, but with some significant limitations.

Structure of a value table as an object

The properties of a value table are determined by combinations of two predefined collections: its columns and rows.

Table of values ​​Columns

A column of a table of values ​​is its defining property. It is the set of table columns that determines its structure. Columns correspond to fields physical tables or columns familiar from the user interface in a tabular section or document journal. A column can have an internal name, a value type, and a title that is displayed when interactive work with a table.

Since columns are a collection of objects, you can add, delete, and edit columns.

Value table row

From point of view software interface, rows are a separate collection embedded in a table of values. They are analogous to records in physical tables, that is, rows familiar to the user in a tabular section or document journal. Each individual row is an object with a set of named properties, the names of which correspond to the names of the table columns.

Thus, interacting with a string is very similar to interacting with other objects. You can read and write its properties, including using the predefined function “FillPropertyValues()”. Since rows are the main collection of the value table, the “Clear()” method is used to delete all rows of the table.

Create table of values

There are many ways to get a table of values ​​ready for use. Let's look at some of them. Each example will be provided as code listings with comments.

Creating a table using the constructor

The main method that allows you to create exactly the table that the developer needs is, unfortunately, the most labor-intensive, since it requires manually specifying all the necessary table properties.

DemoTable = New ValueTable; // First of all, we initialize the technical task // Next we define required parameters for new columns and add them to the collection // Creating the column "Nomenclature" Name = "Nomenclature"; ValueType = New TypeDescription("DirectoryLink.Nomenclature"); Title = "Nomenclature (product)"; DemoTable.Columns.Add(Name, ValueType, Header); // Creating the "Quantity" column Name = "Quantity"; ValueType = New TypeDescription("Number"); DemoTable.Columns.Add(Name, ValueType); // As a result of these manipulations, we created an empty table with typed columns // If you need to use more precise typing of primitive types, then you should use the extended syntax of the “Description of Types” constructor

Creating a table by copying

If you have a reference with a suitable structure and/or composition on hand, you can copy or download the reference table of values. If the reference table is another table, then you need to use the “Copy reference tables” method. If you are dealing with tabular part or a set of register entries, you must use the “Upload table of values” method. If you only need the structure, you can use the “Copy Columns” method.

// Option with copying all rows from the technical specification standard but preserving only the two specified columns. Columns of the Standard = "Nomenclature, Quantity"; DemoTable = TableEtalon.Copy(, ColumnsEtalon); // Option with copying pre-selected rows from the technical specification standard, while preserving the two specified columns. Rows of the Standard = SelectIntoArrayThe Rows We Need From the Table of the Standard(); ColumnsStandard = "Nomenclature, Quantity"; DemoTable = TableEtalon.Copy(RowsEtalon, ColumnsEtalon); // Option for copying rows from the technical specification standard using the specified filter, preserving one column “Nomenclature” // All rows where the value in the Quantity column is 0 will be selected, only the Nomenclature column Row Selection = New Structure("Quantity" will appear in the resulting table , 0); ColumnsStandard = "Nomenclature"; DemoTable = TableEtalon.Copy(RowsEtalon, ColumnsEtalon); // Option with full copying table and subsequent deletion of one row with the value of the quantity field equal to zero and deletion of the entire column “Quantity” Row Selection = New Structure("Quantity", 0); ColumnsStandard = "Nomenclature"; DemoTable = TableEtalon.Copy(RowsEtalon, ColumnsEtalon); TableRow = DemoTable.Find(0, "Quantity"); DemoTable.Delete(TableRow); DemoTable.Columns.Delete("Quantity"); // Similar options and their modifications can be applied to tabular parts and sets of register records

Creating a table with a query

If a template of the table you need exists in the database, then you can use a query to quick creation tables with the required structure.

// An example of creating an empty table based on the structure of the accumulation register // It is easy to guess that in this way you can also get a filled table Query = New Query("SELECT FIRST 0 * From Accumulation Register. Products in Warehouse"); RequestResult = Request.Execute(); DemoTable = Query Result.Unload(); // An example of creating an empty table using explicitly specified types and field names Query = New Query; Query.Text = "SELECT TOP 0 | Value(Directory.Nomenclature.EmptyLink) AS Nomenclature, | EXPRESS(0 AS NUMBER(15, 3)) AS Quantity"; RequestResult = Request.Execute(); DemoTable = Query Result.Unload(); // IMPORTANT! Don’t forget that the types of column values ​​obtained from a request always contain the Null type // Thus, the TK created by the request always has composite column types

Conclusion

In this short article, we looked at the basic properties and practical techniques for creating a table of values, sufficient for understanding and starting to use. The value table object itself is so multifaceted that detailed description its capabilities requires writing a separate article about techniques and methods of work.