Open file 1s 8.3. Mxl than to open

A file with the .MXL extension is a spreadsheet document created by the 1C:Enterprise program. Initially, 1C:Enterprise was intended 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 “File” -> “Open” menu. If desired, you can save such a file in Excel format. To do this, in the same “File” menu, select “Save as..”, and then set the file type to “Excel Table”. If 1C Enterprise is not installed on your computer, you can download and install the free application 1C Enterprise - Working with Files from the company's official website. 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 website. Working with files is similar to working with files in 1C:Enterprise mode.
A Russian version of the program is available. When installing the program, you need to select the full distribution.
After installing “1C Enterprise - Working with Files”, you can not only view a file with the .mxl extension, but also convert it to Excel.

Time moves inexorably forward, and the 1C 8 platform runs even faster than this time.

Managed forms are now called the "TAXI interface", modal windows are prohibited, and the mode of using synchronous calls to extensions and external components has completely stopped the functionality of most of these extensions and external components, and half of the old methods in addition.

In general, guys, things are like this - many of you have read the article by the magnificent P. Chistov about working with files in 8.3

If you haven't done this yet, go ahead and march! ()

The essence of the mechanism for working with files in brief:

1) On the client, select the file

2) We shove it into a black box

3) Save the contents of the black box on the server

The catch is that this must be done especially, in a new way and with soul.

Therefore your

SelectedFile.Exists()

and other pagan things will not work here.

So, let's go!

Here is a code listing that allows you to download a file from the client

Alert Description = New Alert Description("ProcessFileSelection", ThisForm); OpenFileDialog = NewFileSelectDialog(FileSelectDialogMode.Open); FileOpenDialog.MultipleSelect = False; StartFilePlace(AlertDescription, FileOpenDialog, True, UniqueIdentifier);

We are interested in the method " StartPlaceFiles", which, in fact, calls up a file selection dialog and places this file in temporary storage. There is no point in bothering with the description of temporary storage, just remember - this is the place where all the files we select are placed in the form of binary data (black box).

&On the Client Procedure ProcessFileSelection(PlacedFiles, AdditionalParameters) Export If PlacedFiles = Undefined Then Return; endIf; For each TransferredFile From PlacedFiles Cycle PathToFile = TransferredFile.Name; Record.FileName = ParseLine(PathToFile, "\"); Items.OpenFile.Header = Entry.FileName; Address = TransmittedFile.Storage; EndCycle; EndProcedure // ()

It is almost impossible to understand what is there and how to store it in this temporary storage. You can only access our file using the navigation link, which is assigned automatically (see variable " Address").

With the fact that files need to be stored in an attribute or resource with the type " Value storage", I think no one will argue. Get the file from temporary storage and place it in an attribute with the type " Value storage" can be done as follows:

NewValueStorage(GetFromTemporaryStorage(Address));

We’ve sorted out one thing, now the second thing is how to get a file from this value store (which, let me remind you, is located on the server) and save it to the client’s disk?

First of all, we need to get a navigation link to the attribute with type " Value storage", where we place the file in the form of binary data.

Be careful! This navigation link no longer has anything to do with temporary storage! You can check the type of navigation link using the method

This is the Temporary Storage Address (Address)

By tradition, the code listing that calls the file save dialog

Alert Description = New Alert Description("File Saving Processing", ThisForm); File = New DescriptionofTransferFile(FileName, Address); ReceiveFiles = New Array; ReceiveFiles.Add(File); OpenFileDialog = NewFileSelectDialog(FileSelectDialogMode.Save); FileOpenDialog.MultipleSelect = False; StartReceivingFiles(DescriptionAlerts, ReceivingFiles, OpenFileDialog, True);

Variable value " File"This is another feature of this method. It is worth paying attention to" File name"The fact is that when placing a file in temporary storage, information about its name and extension is lost. Therefore, do not forget to save the correct file name, or at least its extension, somewhere, so as not to be bothered with the question later" Is this a Word document or an MP3?"

Method " Start Receiving Files"similar to method" StartPlaceFiles". Simply one opens a dialog to select a file, while the other, on the contrary, opens a dialog to save the file.

That's basically it.

When using this method, there is no need to set any modality and synchronous call compatibility in the configuration properties.

I wrote the article more as a reminder for myself.

The article discusses an example of displaying an image on a controlled form of a directory element when the modality mode fails.

Applicability

The article discusses the 1C:Enterprise platform version 8.3. The information presented is relevant for current platform releases.

Working with files (pictures) in the Taxi interface

Let's look at the algorithm for working with files and pictures in the new 1C:Enterprise 8.3 “Taxi” interface.

Firstly, why I decided to write this article: The new concept of 1C is the abandonment of modal windows, therefore all the methods and objects that generated the opening of modal windows in the new interface will not be able to work, or rather, they will only be able to do so if modal windows are allowed in the configuration properties.

However, if we allow modal windows, we will encounter problems when working in the web client.

Secondly, working with pictures in manageable forms is often asked about.

So, the task: in the “Products” directory, you need to save and display a photo of the product in the form.
The initial configuration does not contain anything except the product directory itself, I will not post it, just create an empty configuration in 8.3.

To store the graphic file itself, in the directory we will create the attribute “Picture Data”, with the type “Value Storage”.

To enlarge, click on the image.

If you plan to upload a picture (file) from the infobase back to the file system, then add another attribute that will store the original file name and its type.

To enlarge, click on the image.

How will we display the image in the form? No, not a “picture” type decoration. And in the form of props of a form with the “string” type. Yes Yes! This is obvious, and it is strange that few people realize this themselves.

The thing is that if you add an attribute with the “string” type to the form, which will contain a navigation link to graphic data or the address of a temporary storage that contains such data, then the form will be able to display the graphic data itself.
Let's add a form attribute with the name “Link To Picture”, type “string”, length is not limited. And put it in the form details.

To enlarge, click on the image.

By default, the line in the form will look like an input field, we need to change this in the properties of the form element. Select “Image Field” in the “View” property.

To enlarge, click on the image.

The interface part is ready. Let's do some coding. Let’s create a form command “Select ImageFile” and place it in the form of a button on the form.

To enlarge, click on the image.

In the module we will describe the “Action” event handler for the created form command:

To enlarge, click on the image.

A couple of comments to the above code:

If we had not paid attention to the application modality mode, we could have easily used the “PlaceFile” method, but the purpose of the article is to show working with files in exactly this mode.
The StartFilePlace method places the selected file in temporary storage (if the file has been selected) and calls the “ProcessFileSelection” procedure in the same module.

I draw your attention to the highlighted “UniqueIdentifier”; with this property we associated the temporary storage with the current form. Otherwise, the file will be placed in the storage, but the storage itself will be destroyed when the server calls, and we will still need it to write the file to the directory attribute.

Let us describe the “ProcessFileSelection” procedure:

To enlarge, click on the image.

If the user does not refuse to select a file, then we place the address in the temporary storage where the image data was placed in the “Link To Picture” form attribute.

Voila!

So, all that remains now when writing a directory element is to write the data from temporary storage into the attribute of the directory element. We describe the BeforeRecordOnServer event:

To enlarge, click on the image.

What do we check in the form details? If the address is temporary storage, we write the data into the directory element attribute, referring to “CurrentObject”, “CurrentObject” is the converted form data that is written to the database at this point in time.

It remains to describe the opening of the form to display the image already saved in the directory element attribute.

To enlarge, click on the image.

That's all. You can take the finished base.

Pavel Chistov

Time moves inexorably forward, and the 1C 8 platform runs even faster than this time.

Managed forms are now called the “TAXI interface”, modal windows are prohibited, and the mode of using synchronous calls to extensions and external components has completely stopped the functionality of most of these extensions and external components, and half of the old methods in addition.

In general, guys, things are like this - many of you have read the article by the magnificent P. Chistov about working with files in 8.3

If you haven't done this yet, go ahead and march! ()

The essence of the mechanism for working with files in brief:

1) On the client, select the file

2) We shove it into a black box

3) Save the contents of the black box on the server

The catch is that this must be done especially, in a new way and with soul.

Therefore your

SelectedFile.Exists()

and other pagan things will not work here.

So, let's go!

Here is a code listing that allows you to download a file from the client

Alert Description = New Alert Description("ProcessFileSelection", ThisForm); OpenFileDialog = NewFileSelectDialog(FileSelectDialogMode.Open); FileOpenDialog.MultipleSelect = False; StartFilePlace(AlertDescription, FileOpenDialog, True, UniqueIdentifier);

We are interested in the method “ StartPlaceFiles“, which, in fact, calls up a file selection dialog and places this file in temporary storage. There is no point in bothering with the description of temporary storage, just remember - this is the place where all the files we select are placed in the form of binary data (black box).

&On the Client Procedure ProcessFileSelection(PlacedFiles, AdditionalParameters) Export If PlacedFiles = Undefined Then Return; endIf; For each TransferredFile From PlacedFiles Cycle PathToFile = TransferredFile.Name; Record.FileName = ParseLine(PathToFile, "\"); Items.OpenFile.Header = Entry.FileName; Address = TransmittedFile.Storage; EndCycle; EndProcedure // ()

It is almost impossible to understand what is there and how to store it in this temporary storage. You can only access our file using the navigation link, which is assigned automatically (see the variable “ Address“).

With the fact that files need to be stored in an attribute or resource with the type “ Value storage“I don’t think anyone will argue. Get the file from temporary storage and place it in an attribute with the type “ Value storage” can be done as follows:

NewValueStorage(GetFromTemporaryStorage(Address));

We’ve sorted out one thing, now the second thing is how to get a file from this value store (which, let me remind you, is located on the server) and save it to the client’s disk?

First of all, we need to get a navigation link to the attribute with type “ Value storage“, where we place the file in the form of binary data.

Be careful! This navigation link no longer has anything to do with temporary storage! You can check the type of navigation link using the method

This is the Temporary Storage Address (Address)

By tradition, the code listing that calls the file save dialog

Alert Description = New Alert Description("File Saving Processing", ThisForm); File = New DescriptionofTransferFile(FileName, Address); ReceiveFiles = New Array; ReceiveFiles.Add(File); OpenFileDialog = NewFileSelectDialog(FileSelectDialogMode.Save); FileOpenDialog.MultipleSelect = False; StartReceivingFiles(DescriptionAlerts, ReceivingFiles, OpenFileDialog, True);

The value of the variable “ File“This is another feature of this method. Here it is worth paying attention to “ File name“. The fact is that by placing a file in temporary storage, information about its name and extension is lost. Therefore, do not forget to save the correct file name somewhere, or at least its extension, so that you don’t have to worry about the question “ Is this a Word document or an MP3?

Method “ Start Receiving Files” similar to the method “ StartPlaceFiles“. One simply opens a dialog for selecting a file, while the other, on the contrary, opens a dialog for saving the file.

That's basically it.

When using this method, there is no need to set any modality and synchronous call compatibility in the configuration properties.

I wrote the article more as a reminder for myself.

The 1C:Enterprise 8 technology platform allows you to save arbitrary files in the information base, retrieve them from there and use them in various ways. Let's look at these operations using examples.

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

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

Uploading an arbitrary file to the 1C information base

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

When converting binary data to an object StorageValues design used new StorageValues(Data, Compression) with two parameters:

  1. Data— binary data that needs to be stored in storage
  2. Compression— compression ratio of the Deflation algorithm. Integer in the range -1...9. -1 is the default compression level. 0 - no compression, 9 - maximum compression. 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 Value Storage 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 file saving dialog, working with which is described in.

//Get binary data from storage
//Data Storage - attribute of an object with the Value Storage type

//Write the 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 information base

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

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

//Receive data from storage
//Data Storage - attribute of an object with the Value Storage type
Data = Datastore. Get() ;

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

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

Share with friends or save for yourself:

Loading...