Technological platform 1C:Enterprise 8 allows you to save arbitrary files in the infobase, get them from there and use them in various ways. Let's look at these operations with examples.

Before uploading a file to the 1C infobase, you need to get the full address of the file on the disk. Working with file selection dialogs is described in .

To store files, an attribute (or register resource) with the type StorageValues.

Uploading an arbitrary file to the 1C infobase

Any file can be represented as binary data and loaded into Value Storage.

When converting binary data to an object StorageValues construction is used newStorageValue(Data,Compression) with two options:

  1. Data- binary data to be placed in storage
  2. Compression— degree of compression of the Deflation algorithm. An integer in the range -1…9. -1 is the default compression level. 0 - no compression, 9 - maximum compression ratio. Default value: -1. The parameter is optional, if not specified, then compression is not used.

//Convert the file to binary data
File = New BinaryData(Path) ;

//Create a new ValueStorage object

DataStorage = NewValueStorage(File, NewDataCompression(9 ) ) ;

Saving an arbitrary file from the 1C infobase to disk

To save a file from the 1C database to disk, you need to determine the path and file name. To do this, there is a dialog for saving files, the work with which is described in .

//Get binary data from storage
//DataStorage - attribute of the object with the ValueStorage type

//Write received data to disk
//The Path variable contains the full address of the file on disk
Data. Write(Path) ;

Viewing a file located in the 1C infobase

To view a file saved in the database, you must have an application installed on your computer that opens this file.

//Get the name of the temporary file with the required extension
//In the variable Extension you need to put the file extension, for example "pdf"
Path= GetTemporaryFileName(Extension) ;

// Get data from storage
//DataStorage - attribute of the object with the ValueStorage type
Data = Datastore. Get() ;

//Write data to a temporary file
Data. Write(Path) ;

//Try to open the file in its intended application
//If the application is not found, the "Open with..." system dialog will appear
StartApplication(Path) ;

Print (Ctrl+P)

AT this section describes the most common options for using the mechanism for working with temporary storage and files.

Saving data from a file to temporary storage

Single file placement

The PlaceFile() method places a file from the local file system into temporary storage. The method can accept an address in temporary storage where the file should be saved. If the address is not defined or is an empty string, then a new address will be created and the method will return it through a special parameter.
Note. The amount of data moved between the client and the server in one call to the PlaceFile() method
If the parameter that determines the interactive mode of operation is True, then the method will display a standard file selection dialog box, in which you can select a file to store in storage. In this case, the method will also return the address of the selected file.
As a result, the method returns False if the user interactively refused to perform the operation in the file selection dialog.

Putting a set of files

Method PlaceFiles() puts multiple files into temporary storage in one call. There are several various ways using this method:
● pre-create a list of files to be added, for example, when pre-selecting the files to be placed in the infobase;
● pass a file search mask to the method, for example, when it is required to place all files of a certain type into the infobase, for example, all pictures;
● pass a previously prepared object to the method FileSelect Dialog in file open mode.
When finished, the method can return a list of actually added files.

// FileList is a form attribute of the ValueList type,
// containing a list of files to add
FileArray = New Array;
For Each ItemList From FileList Loop
Array of Files.Add(New Description of the Transferred File(ListItem,));
EndCycle;
PlacedFiles= New Array;
Result = PutFiles(FileArray, PutFiles, False, UniqueIdentifier);

Note 1. To use the method PlaceFiles() in the web client, you need to connect the extension for working with files.
Note 2: Amount of data moved between client and server per method call PlaceFiles(), should not exceed 4 Gb (in serialized form).

Putting data in temporary storage

The method is similar to the PutFile() method, except that the data to write to temporary storage
are not represented as a path to file system, but as a value. Similarly, if no existing address is specified in temporary storage, a new address is created. The address is returned as the result of the function. As with files, posted data must belong to a form and are automatically deleted when it is deleted.
Note. Amount of data moved between client and server per method call PlaceInTempStorage(), should not exceed 4 Gb (in serialized form).
Attention! When placed in temporary storage, the value is not actually serialized. A link to the value is placed and stored in the cache for 20 minutes. After this period, the value is serialized, written to disk (session storage), and removed from the cache.

Retrieving data from temporary storage

When writing an object to an infobase, you may need to retrieve data from temporary storage and place it, for example, in the attribute of an infobase object. There is a special method for this - GetFromTemporalStorage(). This method retrieves data from temporary storage and returns it as a result of execution. To receive data, you must specify the address in the temporary
storage. This address is returned by methods for putting data into temporary storage if they succeed (see the previous sections).
Attention! When retrieving a value from temporary storage on the server, keep in mind that it is obtained by reference. In fact, this link points to a value that is stored in the cache. Within 20 minutes, from the moment it was placed in the storage or from the moment it was last accessed, the value will be stored in the cache, and then written to disk and removed from the cache. The next time it is accessed, the value is loaded from disk and put back into the cache.
After deserialization and restoration of the value from the temporary storage, the references are not restored. The value in the cache is restored from disk. But after serialization / deserialization, it is impossible to restore references to other objects inside the value.

Deleting data from temporary storage

After the data is saved in the attribute of the infobase object, the data in the temporary storage can be deleted. There is a method for this
DeleteFromTempStorage(), which does the deletion. The method takes as a parameter an address in temporary storage.

Checking if an address belongs to a temporary storage

The address can point both to temporary storage and to details in the infobase. There is a method to check its type
This isTemporalStorageAddress(). It checks that the address passed is an address pointing to a store. Returns True if the address points to temporary storage.

Getting the address of the props

After the data is placed in the attribute of the infobase object, it may be necessary to access it using file methods.
But before getting data, for example, from an attribute, you need to get the address of this attribute. There is a method for this getnavlink().

It can return the address of a value in the infobase based on the original parameters. To do this, you must pass the key of the object (this can be
both a reference to an object and a record key of the information register) and the attribute name. If you need to get the address of the value stored in the attribute
tabular section, then to the attribute name in the parameter that specifies the attribute name, you must add the name of the tabular section and a dot "." For example: Products.Image

Getting a file from the infobase

Getting one file

The GetFile() method receives a file from the infobase and saves it to the user's local file system. The first parameter defines the file address in the attribute of the infobase object or in the temporary file storage. Saving will not occur if the user on behalf of whom the operation is performed does not have the View right on the attribute of the infobase object. The second parameter determines where the resulting file will be saved. In non-interactive mode, you must specify the path. In interactive mode, the parameter is
optional.
By default, the method is executed in interactive mode. This means that a dialog box will be generated in which you can specify an action with the received file: run it or save it to a user-specified location in the file system. If the interactive mode is selected and the File name parameter is not specified, then the file open operation is not available. The method returns a Boolean value. False means that the user has chosen to cancel the operation in the online save file dialog.

Getting a set of files

The GetFiles() method allows you to get and save several files stored in the infobase in the user's local file system. The list of uploaded files is passed as a parameter.

// FileList - a list of values ​​containing references to elements
// directory where uploaded files are located
// Representation of the list of values ​​is the name of the uploaded file
FileArray = New Array;
For Each ItemList From FileList Loop
File = New File(String(ListItem.Value));
GetFile = New Description of the Transferred File;
GetFile.Name = ListItem.View;
GetFile.Storage= P getNavigationLink(ListItem.Value, “Data”);
FileArray.Add(GetFile);
EndCycle;
Received Files= New Array;
Result = GetFiles(FileArray, GetFiles, UploadFilesPath, False);
If NOT Result Then
Message = New MessageToUser;
Message.Text = “Error getting files!”;
Message.Notify();
EndIf ;

When finished, the method can return a list of actually uploaded files, indicating the full name of each saved file.
NOTE. To use the GetFiles() method in the web client, you need to connect the file extension. If the object name property File Transfer Description contains an absolute path to the file, the file will be saved to this path, ignoring the parameter LocationFiles.
The FileLocation parameter can be either a path in the local file system, or a FileSelect Dialog object in the mode of selecting a directory or saving files. If as a parameter value LocationFiles specified object Select Files Dialog in mode
save files, then:

● the dialog will be called for each file being transferred, except for those files for which the object Name property Description of File being transferred contains an absolute path;
● as the initial file name in the dialog, the value of the property Name of the object File being transferred Description will be used;
● if no saving is selected for any file, then the property Name of the SubmittedFileDescription object will contain an empty string;
● the GetFiles() method will return True if at least one file was received successfully;
● keep in mind that the actual receipt of files is performed after the user answers the questions about specifying the name and path
all received files;
● if the user on whose behalf the GetFiles() method is executed does not have the Browse right for at least one attribute of the infobase object from which files are being received, the entire operation will fail.
Example:

TransferredFiles = New Array;
Description = New File Transfer Description(“Description”, FileAddress);
TransferredFiles.Add(Description );
FileSelection = New FileSelectDialog(FileSelectDialogMode.Save);
SelectFile.Header= “Saving archive”;
SelectFile.Extension= "zip";
SelectFile.Filter= “Archive(*.zip)|*.zip|All files|*.*”;
FileSelection.FilterIndex = 0;
GetFiles(TransmittedFiles, FileSelect, False);

If the interactive mode of choosing the directory for saving files is selected, then the web client will additionally request permission to save files specified with absolute paths. In the case of non-interactive saving (the path to the directory is specified in the corresponding parameter), the request will be executed for the entire list of saved files.

An example of using file methods

// Get the file interactively from disk
// and placing it in temporary storage.
&AtClient
Procedure SelectFileCDDiskAndWrite()
Variable SelectedName;
Rem TemporaryStorage Address;
NewObject = Object.Reference.Empty();
If a PutFile(TempStorageAddress, “”, SelectedName, True) Then
Object.FileName = SelectedName;
PlaceObjectFile(AddressTemporaryStorage);
EndIf;
EndProcedure
// Copy file from temporary storage to props
// directory, writing an object, deleting a file from a temporary
// storage.
&On server
Procedure PlaceObjectFile(TempStorageAddress)
Directory Element = FormAttributeToValue("Object");
BinaryData = GetFromTemporaryStorage(AddressTemporaryStorage);
Catalog Element.FileData= New StoreValues(BinaryData, New DataCompression()) ;
File = New File(DirectoryItem.FileName);
Catalog Element.FileName = File.Name;
ElementDirectory.Write();
modified = false;
DeleteFromTemporaryStorage(AddressTemporaryStorage);
ValueVFormAttribute(DirectoryItem, “Object”);
EndProcedure
// Read file from props and save it
// on the local disk interactively.
&AtClient
Procedure ReadFileAndSaveToDisk()
Address = GetNavigationLink(Object.Link,”FileData”);
GetFile(Address, Object.FileName, True);
EndProcedure

Permission to perform a group of file operations

When performing some operations in the web client, you may need to obtain permission for several file operations.
For example, you need to retrieve a document from an infobase and then open the saved document using the associated application.
To perform this operation, you will need to answer the question about saving the document and the question about the need to start. If there are more operations, there will also be more questions for the user.
To reduce the number of questions, you can use the method. When using this method
the user is shown a list of all the operations that are planned to be performed, and is prompted to allow the execution of a group of operations. If the user has allowed execution, then the requested operations will be performed without additional requests user. If permission is not granted, operations will proceed as normal: one request per operation.
NOTE. To use the method RequestUserPermission() in the web client, you need to connect the extension for working with files.
Consider an example of using the method:

If a ConnectFileWorkingExtension() Then
Link = GetNavigationLink(Object.Link, “FileData”);
// Formation of the description of the transferred files (in this case, there is only one file)
Transferred Files= New Array;
Description = New Description of the TransferredFile(Object.FileName, Link);
TransferredFiles.Add(Description);
// Prepare an object to receive information about received files
TransferredFiles= New Array;

// Define other method parameters
CatalogConservation= "c:\temp";
interactive = false ;
TransferredFileName = SaveDir + “\” + Object.FileName;
// Prepare a description of methods for obtaining permissions
Methods = New Array;

Methods.Add("GetFiles");
Methods.Add(UploadedFiles);
Methods.Add(SubmittedFiles);
Methods.Add(SaveDirectory);
Methods.Add(Interactive);
Methods.Add(New Array);
Methods.Add("StartApplication");
Methods.Add(UploadedFileName);
If not RequestUserPermission(Methods) Then
alert("User denied permission.");
Return;
EndIf;
GetFiles(UploadedFiles, UploadedFiles, SaveDir, Interactive);
StartApplication(Name of the TransferredFile);
Otherwise
Warning("Execution is not supported. File extension not installed.");
EndIf;

Several features of the method should be noted. RequestUserPermission().

1. Permission is requested only for the following methods:

GetFiles()/StartGetFiles(),
● PlaceFiles()/StartPuttingFiles(),
● FindFiles()/StartSearchFiles(),
● CopyFile()/StartCopyFile(),
● MoveFile()/StartMoveFile(),
● DeleteFiles()/StartDeleteFiles(),
● CreateCatalog()/StartCreatingCatalog(),
● StartApplication()/StartStartApplication().

2. Permission is requested for a specific set of method parameters. If, during the actual execution of the method of working with files, the values ​​of the parameters differ from those for which the permission was obtained, this permission will not be valid and the user will receive a separate request to confirm the operation.

3. If you need to perform two (or more) identical operations with files (even with the same set of parameters), you should specify the appropriate number of elements in the array of method parameters RequestUserPermission(). For example, if you need to get the same file from the infobase twice and place it in a fixed location in the file system, you should request permission
for two operations.

4. If permission is requested for an operation that performs an interactive operation (for example, the GetFiles() function is passed an object FileSelect Dialog), then such an operation is excluded from the request.

The granted permissions are retained either until the allowed call is made, or until the end of the 1st language execution.
NOTE. in thick and thin clients RequestUserPermission() the method always returns True , with no user interaction.

Working with temporary storage in a background job

In the mechanism of working with temporary storage, it is possible to transfer data from a background job to the session that initiated the background job.
For such a transfer, in the parent session, an empty value should be placed in temporary storage (using the method PutIntoTempStorage()), specifying some identifier of the created temporary storage (Address parameter). Then pass the received address to the background job through the parameters of the background job. Further, if this address is used as the value of the Method Address parameter in the background job PutIntoTempStorage(), the result will be copied to the session from which the background job was started.
Data placed in temporary storage in a background job will not be available from the parent session until the background job completes.

Support for addresses in the picture field

Form element View field An image field supports displaying an image specified by the address of a value (which can be an image or binary data) in temporary storage or in a database.
To do this, in the Data property of the form element, you must specify a string type attribute. The value of this attribute will be interpreted as the address of the image.

// Example 1
// Binding the image field to the image address in a temporary
// storage. ImageAddress – form attribute of string type
PutFile(ImageAddress, SourceName, SelectedName, True, UniqueIdentifier);
// Example 2
// Getting the address of the image from the attribute of the object
// infobase
ImageFile = Object.ImageFile;
If Not ImageFile.Empty() Then
ImageAddress = GetNavigationLink(ImageFile, “FileData”);
Otherwise
ImageAddress = “”;
end if;

Access to standard directories

When using the system, some space is required in the file system, where you can store various file data, which, on the one hand, are temporary, and, on the other hand, must be stored for a sufficiently long time. These files include drafts for document management systems, external components working on the side client computer etc.
These files are stored in a special directory that is linked to a specific user of a specific infobase.
The same user working with two information bases, will have access to two different user data storage directories. The location of this directory is determined using the method WorkingUserDataDirectory(). If the directory does not exist, it is created the first time it is accessed. If the directory cannot be created, the system raises an exception.
NOTE. The UserDataWorkerDir() method is not available on the server side.
AT operating system there is a special directory allocated for permanent storage of user data. It could be some
reports, printed forms of documents, etc. Data is placed in this directory, which can later be sent to external
consumers. The DocumentDirectory() method is used to access this directory. The physical location of the directory depends on the operating system.
system where the application is running and is given in the syntax assistant.

The .MXL file is spreadsheet document created by 1C:Enterprise. Initially, 1C:Enterprise was designed to automate accounting. In our article, we will tell you how to open a file with the .MXL extension.

To open such a file, launch 1C Enterprise and select the menu File -> Open. If desired, you can save this file to Excel format. To do this, all in the same menu "File" select the item "Save as ..", and then set the file type " Excel table". If 1C Enterprise is not installed on your computer, you can download and install free app"1C Enterprise - Working with files" from the official website of the company. This program will help you open, view, print and convert files.

Download "1C Enterprise - Working with files" for free

Download the program from the official site. Working with files is similar to working with files in 1C:Enterprise mode.
Available Russian version programs. When installing the program, you need to select the full distribution.
After installing 1C Enterprise - Working with Files, you can not only view the file with the .mxl extension, but also convert it to exel.

The program "1C:Enterprise - Working with files" is a separate software which is distributed free of charge. It is intended for viewing and editing 1C:Enterprise files on those computers where 1C:Enterprise is not installed.

The following file formats are supported:

  • (*.txt);
  • (*.mxl);
  • (*.htm, *.html);
  • (*.grs);
  • (*.geo);

During the installation process, the program registers the mxl, grs and geo extensions, as a result of which, to view and edit these files, it is enough to click on them with the mouse:

Supports running the program from command line. In this case, it is possible to specify the file to be processed. For example, to process the "Remains.mxl" file, it is enough to execute the command:

"D:\Program Files\1cv82fv\bin\1cv8fv.exe" D:\FileWorkshop\Remains.mxl

"1C:Enterprise - Working with files" supports , similar to the mode implemented in the 1C:Enterprise system. Thus, for example, the user can visually compare two balance reports:

Delivery options

There are two delivery options for 1C:Enterprise - Working with files:

  • Russian-speaking;
  • international.

The difference between an international delivery and a Russian-language one is that it includes the same ones that the 1C:Enterprise system uses.

Also, for international delivery, the /L command line switch can be used to specify the interface language used. For example, to process the file "Remains.mxl" in a program with English language interface (en), just run the command:

"D:\Program Files\1cv82fv\bin\1cv8fv.exe" /Len D:\FileWorkshop\Remains.mxl