1c creation of a table of values. What methods exist and how to search for several values ​​simultaneously

Published September 21, 2011

Table of values ​​1C – part 3. Metadata. Looping through value table columns

In this article I will tell you how to work with a table of values ​​of an “unknown” structure, how to iterate through the columns of a table of values, how to extract data from columns and rows without using column names. (This article belongs to the series of articles 1C from scratch; programming 1C from scratch; table of 1C values)

To explain the material and to be able to run our code examples “live”, we need some test table of values ​​1C. Some of our examples will extract data from a table of values, so we will make a table with three columns “Last name”, “First name”, “Middle name” and enter a small amount of data into it - as many as 3 rows :)

So, let's create a test table of 1C values ​​and fill it in:

MyTZ = New ValueTable; // create a new table of values ​​stored in the variable "MyTZ" MyTZ.Columns.Add("Last Name"); // create the column "Last Name" MyTK.Columns.Add("Name"); // create the column "Name" MyTZ.Columns.Add("Patronymic"); // create the "Middle name" column // add the first row to our table of values ​​NewLine = MyTZ.Add(); NewString.LastName = "Chapaev"; NewLine.Name = "Vasily"; NewString.Middle name = "Ivanovich"; // add the second line NewLine = MyTZ.Add(); NewString.LastName = "Dzerzhinsky"; NewRow.Name = "Felix"; NewString.Middle name = "Edmundovich"; // add the third line NewLine = MyTZ.Add(); NewLine.LastName = "Kotovsky"; NewLine.Name = "Gregory"; NewString.Middle name = "Ivanovich";

Our test table consists of three columns: First Name, Last Name, Patronymic; and has three filled lines with the names of Civil War heroes.

The first code sample is enumerating the columns of a 1C value table as a collection.

// display the names of all columns of the TK For Each Column From MyTZ.Columns Cycle Report("Column name: " + Column.Name); EndCycle;

Our cycle will display all column names in the 1C message window:

Column name: Last name Column name: First name Column name: Middle name

We see that to iterate through columns, a special collection iteration cycle is used, similar to the row iteration cycle (in the previous article). MyTK.Columns- this is a collection of columns of the 1C value table "MyTZ". The collection contains objects of the type "Value Table Column" Each object of this type is a column of the value table and contains properties and methods. By accessing these properties and methods, we obtain the necessary information about one column or perform some other actions with it.

For example, accessing the property "Name" (Column.Name) we get the name of the current column.

I would like to draw your attention to the title of the series: “For Everyone Column From MyTZ.Column Cycle" Variable with name "Column" invented by us. It is not necessary to use the same name. You can call this variable anything you like, for example "MyCurrentColumn" Then the example above would look like this:

// display the names of all columns of the TK For Each MyCurrentColumn From MyTK.Columns Cycle Report("Column name: " + MyCurrentColumn.Name); EndCycle;

When the 1C execution subsystem encounters a cycle of this type, with each pass of the cycle it assigns to a variable with the specified name one element from our collection, in this case - one collection element value table columns MyTK.Columns And then we access the variable that contains the current column and use the property "Name".

I propose to display next to the column name the number of each column in the collection of columns:

// display the number and names of all columns of the table of values ​​For Each Column From MyTZ.Columns Cycle ColumnNumber = MyTZ.Columns.Index(Column); // get the column number ColumnName = Column.Name; // get the column name Report("Column Number:" + Column Number + " Column Name: " + Column Name); EndCycle;

The following text will be displayed in the 1C message window:

Column number:0 Column name: Last name Column number:1 Column name: First name Column number:2 Column name: Middle name

Please note that the columns in the 1C value table are numbered starting from zero, just like the rows of the value table.

Number of columns in the 1C value table

To find out the number of columns in the table of values, we use the "Count()" method on the collection of columns.

Number of Columns = MyTZ.Columns.Quantity(); Report(Number of Columns);

The number "3" will be displayed on the screen. Indeed, our table has three columns: “Last name”, “First name”, “Patronymic”

Getting a column object by its number (index) and enumerating columns using the column index

Let's make a cycle of searching through all the columns of the value table using column indices (numbers). Remember that column numbering starts from zero. Therefore, we must increase the cycle counter “Sch” from zero to a number equal to the number of columns minus one.

For Account = 0 By MyTZ.Columns.Quantity() - 1 Cycle CurrentColumn = MyTZ.Columns[Act]; Report(CurrentColumn.Name); EndCycle;

On the screen we will get the following

Full Name

I think this example was clear. We turned to the method Quantity() column collections" MyTZ.Columns.Quantity()", got the number of columns, and started a loop with a counter from zero before number of columns minus one. Inside the loop we get each column from the collection of columns and assign the current column object to a variable CurrentColumn Next, the variable CurrentColumn we access the property Name and display the value of this property on the screen: Report(CurrentColumn.Name);

It is important to never confuse an object's property and an object's method.

A property is a certain static value and access to it is written without parentheses, for example CurrentColumn.Name. A method is essentially a procedure or function of an object, and calls to procedures and functions are always written with parentheses (even if there are no input parameters). For example: MyTZ.Columns.Quantity()

If we access a method and forget to write the parentheses, the 1C interpreter will give us an error message and will not run the code. Since the interpreter will consider that we are not accessing a method, but a property - because there are no parentheses. But it will not be able to find properties with that name (because there is only a method with that name) - which will be stated in the error message.

This is what the interpreter will write if I forget to put parentheses in a method call in such an incorrect way MyTZ.Columns.Quantity(without parentheses after "Quantity()"):

Object field not found (Quantity)

In this case, “field” and “property” should be understood as synonyms, or an inaccuracy in the terminology of 1C developers. They use both of these words to refer to the same concept. Although in other programming languages ​​these terms may mean different things.

Obtaining data from a table of 1C values ​​using column numbers

To begin with, I offer you a simple example of obtaining data from the first row of our table. Please note that we are using the pre-populated table from the beginning of the article. We know for sure that the table has a first row and at least one column. If we apply this example to an empty table, an error will occur. So:

FirstLine = MyTK; // get the first row (numbered from zero) FirstColumnValue = FirstRow; // get the value of the first column (column numbering is also from scratch) Report(Value of the FirstColumn); // display the value of the first column in the first row of the table

The screen will display:

Chapaev

First, we obtained a value table row object by accessing the value table using the [...] operator. (if you forgot how to do this, you can look at previous articles) We passed the argument “0” inside the operator. This is the index of the first row of the value table. FirstLine = MyTK;

Further, we also have the right to access a string object using the [...] operator. Inside this operator we passed the column number of the value table, in this case also “0”. And thus, we received the value of the column numbered "0" for the current table row numbered "0". We displayed this value on the screen and it represents the string “Chapaev”.

Let's complicate our example a little:

FirstLine = MyTK; // get the first line (numbered from zero) Report(FirstLine); // display the value of the first column in the first row of the table Report(FirstRow); // display the value of the second column in the first row of the table Report(FirstRow); // display the value of the third column in the first row of the table

We have now displayed the values ​​from all three columns of the first row of our value table:

Chapaev Vasily Ivanovich

Now I will also modify this example so that we can do without the variable "First line"

Report(MyTZ); // display the value of the first column in the first row of the table Report(MyTZ); // display the value of the second column in the first row of the table Report(MyTZ); // display the value of the third column in the first row of the table

It will be the same on the screen

Chapaev Vasily Ivanovich

We saw in the example above that to access a value located in a specific row and a specific column of a table of values, we can use a sequential call of two operators [...] in this form: Value Table[Row Index][Column Index]

So, we are ready to create a loop and get the data of all rows and all columns using row and column indices:

For RowCounter = 0 By MyTZ.Quantity() - 1 Loop // cycle through rows For ColumnCounter = 0 By MyTZ.Columns.Quantity() - 1 Loop // nested loop through columns // get the cell value (from the current row and the current columns) CellValue = MyTK[RowCounter][ColumnCounter]; // display the row number, column number and cell value Report("Row No" + Row Count + "column No" + Column Count + " = " + CellValue); EndCycle; EndCycle;

The following will be displayed on the screen:

Line No. 0 column No. 0 = Chapaev Line No. 0 column No. 1 = Vasily Line No. 0 column No. 2 = Ivanovich Line No. 1 column No. 0 = Dzerzhinsky Line No. 1 column No. 1 = Felix Line No. 1 column No. 2 = Edmundovich Line No. 2 column No. 0 = Kotovsky Line No. 2 column No. 1 = Grigory Line No. 2 column No. 2 = Ivanovich

Using two cycles, one of which is nested within the other, we displayed the values ​​of all columns from all rows of the 1C value table. In this case, we did not use column names, but accessed columns and rows by their indexes. For more understanding, pay attention to the comments inside the example.

In conclusion, I propose to slightly change our example so that instead of column numbers, it displays their names on the screen. And in addition, I will make a more presentable design for displaying content on the screen.

For LineCounter = 0 By MyTZ.Quantity() - 1 Loop // loop through rows Report(" ======= Line No. " + LineCounter + " ======="); To report(" "); // line feed (inserting an empty row) For ColumnCounter = 0 By MyTZ.Columns.Quantity() - 1 Loop // nested loop through columns // get the cell value (from the current row and the current column) CellValue = MyTZ[RowCounter][ ColumnCounter]; // get the name of the column ColumnName = MyTZ.Columns[ColumnCounter].Name; // display the column name and cell value Report(ColumnName + ": " + CellValue); EndCycle; To report(" "); // line feed (inserting an empty line) EndCycle;

Now, on our screen the information began to look more representative:

Line No. 0 ======= Last name: Chapaev First name: Vasily Patronymic: Ivanovich ======= Line No. 1 ======= Last name: Dzerzhinsky First name: Felix Patronymic: Edmundovich ===== == Line No. 2 ======= Last name: Kotovsky First name: Grigory Patronymic: Ivanovich

Yes, I almost forgot. When using two [...][...] operators in a row, we can pass the name of this column instead of a column index: ValueTable[RowIndex][ColumnName]

For LineCounter = 0 By MyTZ.Quantity() - 1 Loop // loop through rows Report(" ======= Line No. " + LineCounter + " ======="); To report(" "); // line feed (inserting an empty line) For ColumnCounter = 0 By MyTZ.Columns.Quantity() - 1 Loop // nested loop through columns ColumnName = MyTZ.Columns[ColumnCounter].Name; // get the column nameCell Value = MyTZ[RowCounter][ColumnName]; //

Pay attention to the line marked with an arrow ". In this line, instead of the index of the current column, we pass the name of the current column to the argument in square brackets [...] The result will be the same.

And now, the last thing in this article.

CORRECTLY obtaining all data from the 1C value table using loops through a collection of rows and a collection of columns

For Each CurrentLine From MyTZ Loop // loop through a collection of strings Report(" ======= Line No. " + MyTZ.Index(CurrentLine) + " ======="); To report(" "); For Each CurrentColumn From MyTZ.Columns Loop // nested loop iterating through a collection of columns ColumnName = CurrentColumn.Name; // get the column nameCellValue = CurrentRow[ColumnName]; // get the cell value BY column NAME Report(ColumnName + ": " + CellValue); // display the column name and cell value End of Cycle; To report(" "); EndCycle;

In the example, two loops were used. A loop for looping through a collection of columns is nested inside a loop for looping through rows. If you have worked through the examples above and read previous articles, then you will not have any difficulty understanding how this example works.

Finally, I will reduce the number of lines of code in our last example as much as possible by eliminating the use of intermediate variables. We will get a sample of "industrial code" that is used in real problems.

This should only be done when you have a good understanding of what you are doing. If the code is very complex, then it is acceptable to leave intermediate variables to make it easier to understand your own code later. Also, any code must be commented at least minimally, so that after some time it will be easier to understand the program texts.

For Each CurrentLine From MyTZ Cycle // iterate over rows Report(" ======= Line No. " + MyTZ.Index(CurrentLine) + " =======" + Symbols.PS); For Each CurrentColumn From MyTZ.Columns Loop // iterate over columns Report(CurrentColumn.Name + ": " + CurrentRow[CurrentColumn.Name]); EndCycle; To report(" "); EndCycle;

The output on the screen has not changed, it remains the same as in the previous example:

2 WEEK COURSE

"PROGRAMMING IN 1C FOR BEGINNERS"

The course will be sent by email. Become a programmer by completing step-by-step tasks.

To participate you only need a computer and the Internet

Free access to the course:

Sp-force-hide ( display: none;).sp-form ( display: block; background: #eff2f4; padding: 5px; width: 270px; max-width: 100%; border-radius: 0px; -moz-border -radius: 0px; -webkit-border-radius: 0px; font-family: Arial, "Helvetica Neue", sans-serif; background-repeat: no-repeat; background-position: center; background-size: auto;) .sp-form input ( display: inline-block; opacity: 1; visibility: visible;).sp-form .sp-form-fields-wrapper ( margin: 0 auto; width: 260px;).sp-form .sp -form-control ( background: #ffffff; border-color: #cccccc; border-style: solid; border-width: 1px; font-size: 15px; padding-left: 8.75px; padding-right: 8.75px; border -radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; height: 35px; width: 100%;).sp-form .sp-field label ( color: #444444; font- size: 13px; font-style: normal; font-weight: bold;).sp-form .sp-button ( border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; background-color: #f4394c; color: #ffffff; width: 100%; font-weight: 700; font-style: normal; font-family: Arial, "Helvetica Neue", sans-serif; box-shadow: none; -moz-box-shadow: none; -webkit-box-shadow: none; background: linear-gradient(to top, #e30d22 , #f77380);).sp-form .sp-button-container ( text-align: center; width: auto;)

(This article belongs to the series of articles 1C from scratch; programming 1C from scratch; table of 1C values)

A virtual data storage structure in tabular form - that’s what it is

The table of values ​​is not a permanent object of the 1C database and is not saved between launch sessions.

Table of values ​​1C(TK) is created “on the fly” using program code, and then work with it is carried out in the same way as with any other program object of the 1C programming language. Using method calls and accessing the properties of a table-object.

In other words, the programmer creates a table in memory, fills it with data, works with it, sorts, groups, calculates totals, and so on. Receives the necessary data for further use.

Let's create a table of values ​​and fill it with something. It must be remembered that a table of 1C values ​​can be created not only manually, by calling the operator

NewValueTable;

A value table is often the result of a method call on another object, for example the result of a query might be dumped into a value table, and so on.

Let me give you a simple example right away.

// MyTZ = New ValueTable; // create a new table of values ​​stored in the variable "MyTZ" MyTK. Columns. Add("LastName" ) ; // create the column "Last Name" MyTZ. Columns. Add("Name"); // create the "Name" column Report (MyTZ); // display the value of the MyTZ variable //

I created a table of 1C values, with two columns: “Last name”, “First name”. Procedure Report(MyTK) will display the variable type in the message window MyTZ: Table of Values

Our value table is empty for now. Let's add a couple of lines to it, with first and last names.

// fill the table of values // add the first row to our value table NewLine = MyTZ. Add() ; New line. Last name = "Sidorov" ; New line. Name = "Vasya" ; // add a second row to our value table NewLine = MyTZ. Add() ; New line. Last name = "Ivanov" ; New line. Name = "Peter" ;

We received a table like this:

Need to remember: Row numbers in the value table start from zero

Why do we even need line numbers? And so that we can access a separate row of the table of values, for example, take and display this row on the screen.

// *** display the values ​​of the zero line on the screen *** (in everyday life we ​​usually number things starting from one, but here - from zero) // get the zero row of our table using the row index in square brackets OurNullString = MyTZ[ 0] ; // now the entire zero string is contained in the variable "OurFirstLine" Report(OurNullString.LastName) ; // display the value of the "Last Name" column stored in row zero Report (OurNullString.Name) ; // display the value of the "Name" column from the same line

As a result, the screen will display:

Sidorov Vasya

Now, for the very smart and concise, I will show an example that allows you to access the value of a column in such and such a row (The value of a column in such and such a row is a cell of the table of values. An unofficial term, but a convenient one). But without using an intermediate variable like "OurZeroString".

To display the value of cells from the second row (do not forget that the row is the second, but the index of this row is one, so the numbering starts from zero)

Finally, the final point in this article. I showed you an example of accessing a single row of a value table by index (row number). The universal form for reading or assigning the contents of a cell is: "MyValueTable[RowNumber].ColumnName"

Now I’ll give you a cycle of complete output of the contents of the table of values. Without detailed explanations, so that you can also rack your brains :)

// // loop through and display all rows of our table of values// For LineNumber = 0 According to MyTZ. Quantity() - 1 Cycle Report (MyTZ[LineNumber] . LastName) ; // display the value of the "Last Name" column Report (MyTK[LineNumber] . Name) ; // display the value of the "Name" column EndCycle ;

As a result of running this loop, the following will be displayed on the screen:

Sidorov Vasya Ivanov Petya

Here I told you the very basics of working with the 1C table of values. This information applies to 1C 8.0, 8.1, 8.2. The interesting details about the “1C value table” object do not end there. This object has enormous capabilities for convenient work with data. I will talk about this in the following articles.

Degtyarev Roman.

How to learn to program in 1C from scratch?

How to work as a 1C programmer and earn up to 150,000 rubles per month?

SIGN UP FOR FREE

2 WEEK COURSE

"PROGRAMMING IN 1C FOR BEGINNERS"

The course will be sent by email. Become a programmer by completing step-by-step tasks.

To participate you only need a computer and the Internet

Free access to the course:

Sp-force-hide ( display: none;).sp-form ( display: block; background: #eff2f4; padding: 5px; width: 270px; max-width: 100%; border-radius: 0px; -moz-border -radius: 0px; -webkit-border-radius: 0px; font-family: Arial, "Helvetica Neue", sans-serif; background-repeat: no-repeat; background-position: center; background-size: auto;) .sp-form input ( display: inline-block; opacity: 1; visibility: visible;).sp-form .sp-form-fields-wrapper ( margin: 0 auto; width: 260px;).sp-form .sp -form-control ( background: #ffffff; border-color: #cccccc; border-style: solid; border-width: 1px; font-size: 15px; padding-left: 8.75px; padding-right: 8.75px; border -radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; height: 35px; width: 100%;).sp-form .sp-field label ( color: #444444; font- size: 13px; font-style: normal; font-weight: bold;).sp-form .sp-button ( border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; background-color: #f4394c; color: #ffffff; width: 100%; font-weight: 700; font-style: normal; font-family: Arial, "Helvetica Neue", sans-serif; box-shadow: none; -moz-box-shadow: none; -webkit-box-shadow: none; background: linear-gradient(to top, #e30d22 , #f77380);).sp-form .sp-button-container ( text-align: center; width: auto;)

Greetings to all readers of infostart. This article will be devoted to the issue of creating an arbitrary table of values ​​on the form of a managed application programmatically.

Features of the task.

Anyone who has programmed in a regular application has often been faced with the task of obtaining an arbitrary table of values ​​on a form. An arbitrary table of values ​​is a table whose number and type of columns are not known in advance. That is, there could be 3 columns, or maybe 6, or maybe 8. In a normal application, everything is simple: you could place the “Table of Values” element on the processing form, and then transfer the created table of values ​​to this element programmatically. Then with a simple command:

Form Elements.TableField.CreateColumns();

get a ready-made table of values ​​on the form. It would seem that it could be simpler.

This was all in the regular application. In a managed application, everything has changed. It’s not that easy to create an arbitrary table. Now you need to either rigidly parameterize the table of values ​​on the form, or create it programmatically (describe, well, this, in fact, is the essence of the managed application itself). This is what we will try to do: programmatically create an arbitrary table of values ​​on a controlled form.

The solution of the problem.

The first thing we need to do is determine how the table will appear on the form. The main thing is that you don’t need to create any form element in processing. We will create it programmatically, like the entire table. That is, the table will be described and created at the moment of opening the form or using a button - depending on who needs it.

The creation of a table on the form occurs through the description of the value table as an attribute:
SelectionTypeArray = New Array; Array of SelectionType.Add(Type("Value Table")); ChoiceTypeDescription = New TypeDescription(ChoiceTypeArray); Array of Details = New Array; Array of Attributes.Add(New Form Attributes("Schedule Table", Description of SelectionType, "", "TZN")); Now we need to create a programmatic table of values ​​that contains the data. If the table of values ​​is obtained from a query, then everything is more or less in order. If the table is created manually, then the meaning of the columns that will contain numbers or dates can be created through the “Description of Types”. The point is that the columns in the table of values ​​must have some type. If, for example, it is expected that the user will fill in data in these columns interactively, then you cannot add a column of the value table simply with a name; it must have a type. Keep in mind - this is very important because... We will transfer these types to the table on the form.
We create a table that contains several columns:
CD = NewDateQualifiers(DateParts.Time); ArrayKD = New Array; ArrayCD.Add(Type("Date")); DescriptionTypesTime = New DescriptionTypes(ArrayCD,CD); TZ = New ValueTable;
TK.Columns.Add("With", DescriptionTypesTime);
TK.Columns.Add("Before", DescriptionTypesTime);
TK.Columns.Add("Name");
TK.Columns.Add("Note"); // Full name and Note - rows Next, we will fill our TK program table with the necessary data. We receive a TK table that contains the necessary values ​​and is ready to be transferred to the created form attribute. For Each Column From TK. Columns Cycle

Array of Attributes.Add(New Form Attributes(Column.Name, Column.ValueType,"ScheduleTable"));
EndCycle;
ChangeDetails(ArrayDetails);
SelectionFieldsTable = Elements.Add("TZN", Type("FormTable"));
SelectionFieldsTable.DataPath = "ScheduleTable";
SelectionFieldTable.Display = TableDisplay.List;

This is a simple combination and our table is ready.

For Each Column From TK. Columns Cycle

NewElement = Elements.Add(Column.Name, Type("FormField"), SelectionFieldTable);
NewElement.View = FormFieldView.InputField;
NewElement.DataPath = "ScheduleTable." + Column.Name;
NewElement.Width = 10;
EndCycle;

Conditional design, if we need it, we also write it manually, the command menu - manually. Table handlers are also written by hand. For example, to add an event handler for the “Selection” table:

Table of SelectionFields.SetAction("Selection","TZNSelection");

To process this event, a separate procedure is prescribed in the form of a procedure:

&OnClient
Procedure TKNSelection(TK, SelectedRow, Field, StandardProcessing)
//handler commands EndProcedure

Note that table handlers fire on the client and therefore must have a compiler pointer command

&OnClient

Well, the last thing I wanted to add is that after all these steps, be sure to remember to pass the finished table to the form attribute:

ValueВFormAttributes(ToR, "ScheduleTable");

This is what we have as a result:


And here is the handling of the "Selection" event:



Afterword.

I hope the article will help those 1C programmers who are starting to create tables on a form programmatically.

You can download a processing that programmatically creates a table of values ​​and displays it on a manageable form with comments that will help you create your own tables.

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.

By right-clicking 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 a managed form, these actions 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.

Question Creating a table column of values ​​of various types in 1C v8
Answer
When creating a value table column, you can pass array of types, and maybe a specific type. An array of types is used when you need to specify several different types for one column.

Used to indicate types “general object” - “Description of types”. Therefore, first we will explain what “Description of types” (“Description of value types”) is.

"Description of value types". To describe the acceptable types of property values ​​of various objects in the system, a special object is used "Description of Types". Using this object, you can describe the valid types of values ​​that can be assigned to properties. To further limit the possible values ​​of the primitive types Number, String and Date are provided qualifiers. Qualifiers describe parameters such as the length of a string or number, valid parts of a date, etc.

Syntax of the “Type Description” method

New DescriptionTypes(<Исходное описание типов>, <Добавляемые типы>, <Вычитаемые типы>, <Квалификаторы числа>, <Квалификаторы строки>, <Квалификаторы даты>)
Options:
<Исходное описание типов> (optional)
Type: DescriptionTypes. The initial description of types, on the basis of which a new one will be built.
<Добавляемые типы> (optional)
Type: Array, String. An array of type values ​​A Type consisting of the types that will be used in the object, or a string containing the names of the types separated by commas.
<Вычитаемые типы> (optional)
Type: Array, String. An array of Type values ​​(or a string containing comma-separated type names) consisting of the types that will be excluded from the initial declaration specified in the first parameter.
<Квалификаторы числа> (optional)
Type: QualifiersNumbers. Number qualifiers that describe valid values ​​of a numeric type.
<Квалификаторы строки> (optional)
Type: QualifiersStrings. String qualifiers that describe valid values ​​of a string type.
<Квалификаторы даты> (optional)
Type: QualifiersDates. Date qualifiers that describe valid values ​​of the Date type.
Description:
Creates a type description based on another type description, by adding some types and excluding others. If a new qualifier is not specified, the qualifiers of the original type declaration will be retained.
An example of using the “Type Description” object:

// expand the description of Valid Types with new types Array = New Array; Array. Add(Type( "Reference Link. Methods")); Array. Add(Type("Number" )); Sign = ValidSign. Non-negative; QuNumbers = New QualifiersNumbers(10, 2, Sign); ValidTypes = NewTypeDescription(ValidTypes, Array, KvNumbers);
Now, in fact, examples of correct creation of column values ​​of various types in a table.

In general, it is enough to define the column types as follows:

TK. Columns. Add( "Sort Index", New DescriptionTypes ( "Number" ) ) ; TK. Columns. Add("SectionName", New TypeDescription("String" ) ) ; TK. Columns. Add("DataCorr" , New TypeDescription("Date" ) ) ; TK. Columns. Add( "UnconditionalDeletion", New TypeDescription("Boolean")); TK. Columns. Add("Nomenclature" , New TypeDescription() ) ; TK. Columns. Add("SectionData" , New TypeDescription("Structure" ) ​​) ; // example of creating columns "number" and "string" with clarification of parameters: TK. Columns. Add( "Percent Complete", New DescriptionTypes ( "Number" , New QualifiersNumbers ( 18 , 2 ) ) ) ; TK. Columns. Add("SectionName" , NewTypeDescription("String" , , NewStringQualifiers(200, AllowedLength. Variable) ) ) ; TK. Columns. Add("DecommissionedDate" , NewTypeDescription("Date" , , , NewDateQualifiers(DateParts.DateTime) ) ) ;

However, more generally, an array is passed as the column type. An array is used when several types need to be assigned to one column. Then the definition of the structure will be something like this (examples are given for different types of columns, when the type is an array, but for simplicity, the composition of the array is given of the same type, so as not to get confused)

////// formation of the structure of the technical specifications (creation of columns) //// define qualifiers for substitution in the qualifier fields of the technical specification CN = New QualifiersNumbers(18, 9); KS = NewStringQualifiers(200); CD = NewDateQualifiers(DataParts.DateTime) ; //// define type descriptions for future TK columns // An array is the initial description of types, on the basis of which a new one will be built // Please note that for TK columns the initial type description in this example is an array Array = New Array; Array. Add(Type("String") ) ; TypeDescriptionString = New TypeDescription(Array, , KS) ; Array. Clear() ; Array. Add(Type("Number") ) ; TypeDescriptionNumber = New TypeDescription(Array, , , CN) ; Array. Clear() ; Array. Add(Type("Date") ) ; DescriptionTypesDate = New DescriptionTypes(Array, , , , CD) ; Array. Clear() ; Array. Add(Type( "DirectoryLink.Nomenclature") ) ; Type DescriptionNomenclature = New Type Description (Array) ; Array. Clear() ; Array. Add(Type( "DirectoryLink.SeriesNomenclature") ) ; TypeDescriptionSeries = New TypeDescription(Array) ; Array. Clear() ; Array. Add(Type( "DirectoryLink.Quality") ) ; TypeDescriptionQuality = New TypeDescription(Array) ; Array. Clear() ; Array. Add(Type("Boolean") ) ; TypeDescriptionBoolean = New TypeDescription(Array) ; // actually adding columns to the TK (creating the structure of the future TK) TK. Columns. Add("Nomenclature", DescriptionTypesNomenclature) ; TK. Columns. Add("Code" , TypeDescriptionString) ; TK. Columns. Add( "SeriesNomenclature", DescriptionTypesSeries); TK. Columns. Add("AccountCode" , Type DescriptionString) ; TK. Columns. Add("ActionDate" , TypeDescriptionDate) ; TK. Columns. Add("Quality" , TypeDescriptionQuality) ; TK. Columns. Add("NumberUS", DescriptionTypesNumber) ; TK. Columns. Add("Write off" , TypeDescriptionBoolean) ; . . . //////// formation of the structure of the technical specifications (creation of columns) ////////////////////////////////////////////////////////

To add a row to a value table, see