I'm currently using 1C:ERP and I'm writing a module to import data from Excel file, but I'm going to work with several types of Excel file, each of them has another file name, so I'm wondering how can we get the file name when we select a file
&AtClient
Procedure FillFromFile(Command)
FileDialog = New FileDialog(FileDialogMode.Open);
FileDialog.Title = "Choose file";
FileDialog.Filter = "Tabular document|*.xlsx";
NotifyDescription = New NotifyDescription("FillFromFile_NotifyDescription", ThisObject);
FileDialog.Show(NotifyDescription);
EndProcedure
&AtClient
Procedure FillFromFile_NotifyDescription(SelectedFiles, AdditionalParameters) Export
If SelectedFiles <> Undefined Then
BinaryData = New BinaryData(SelectedFiles[0]);
StorageFilePath = PutToTempStorage(BinaryData);
FillFromFileAtServer(StorageFilePath, SelectedFiles[0]);
EndIf;
EndProcedure
You can create an extra method GetNameFile(). For example, "C:\Users\1c\AppData\Local\Temp\Excel.xlsx"
&AtServer
Function GetNameFile(FileDirectory)
Post = Find(FileDirectory,"\");
While Post<>0 Do
FileDirectory = Right(FileDirectory,StrLen(FileDirectory) - Post);
Post = Find(FileDirectory,"\");
EndDo;
Return FileDirectory;
EndFunction
You will get "Excel" in return