dolibarr 21.0.0-alpha
ImportXlsx Class Reference

Class to import Excel files. More...

Inheritance diagram for ImportXlsx:
Collaboration diagram for ImportXlsx:

Public Member Functions

 __construct ($db, $datatoimport)
 Constructor.
 
 write_header_example ($outputlangs)
 Output header of an example file for this format.
 
 write_title_example ($outputlangs, $headerlinefields)
 Output title line of an example file for this format.
 
 write_record_example ($outputlangs, $contentlinevalues)
 Output record of an example file for this format.
 
 write_footer_example ($outputlangs)
 Output footer of an example file for this format.
 
 import_open_file ($file)
 Open input file.
 
 import_get_nb_of_lines ($file)
 Return nb of records.
 
 import_read_header ()
 Input header line from file.
 
 import_read_record ()
 Return array of next record in input file.
 
 import_close_file ()
 Close file handle.
 
 import_insert ($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys)
 Insert a record into database.
 
- Public Member Functions inherited from ModeleImports
 __construct ()
 Constructor.
 
 getDriverId ()
 getDriverId
 
 getDriverLabel ()
 getDriverLabel
 
 getDriverDesc ()
 getDriverDesc
 
 getDriverExtension ()
 getDriverExtension
 
 getDriverVersion ()
 getDriverVersion
 
 getLibLabel ()
 getDriverLabel
 
 getLibVersion ()
 getLibVersion
 
 listOfAvailableImportFormat ($db, $maxfilenamelength=0)
 Load into memory list of available import format.
 
 getPictoForKey ($key)
 Return picto of import driver.
 
 getDriverLabelForKey ($key)
 Return label of driver import.
 
 getDriverDescForKey ($key)
 Return description of import drivervoi la description d'un driver import.
 
 getDriverVersionForKey ($key)
 Renvoi version d'un driver import.
 
 getLibLabelForKey ($key)
 Renvoi libelle de librairie externe du driver.
 
 getLibVersionForKey ($key)
 Renvoi version de librairie externe du driver.
 
 getElementFromTableWithPrefix ($tableNameWithPrefix)
 Get element from table name with prefix.
 

Detailed Description

Class to import Excel files.

Definition at line 41 of file import_xlsx.modules.php.

Constructor & Destructor Documentation

◆ __construct()

ImportXlsx::__construct ( $db,
$datatoimport )

Constructor.

Parameters
DoliDB$dbDatabase handler
string$datatoimportString code describing import set (ex: 'societe_1')

Definition at line 114 of file import_xlsx.modules.php.

References dol_syslog(), versioncompare(), and versionphparray().

Member Function Documentation

◆ import_close_file()

ImportXlsx::import_close_file ( )

Close file handle.

Returns
integer

Reimplemented from ModeleImports.

Definition at line 367 of file import_xlsx.modules.php.

◆ import_get_nb_of_lines()

ImportXlsx::import_get_nb_of_lines ( $file)

Return nb of records.

File must be closed.

Parameters
string$filePath of filename
Returns
int Return integer <0 if KO, >=0 if OK

Reimplemented from ModeleImports.

Definition at line 285 of file import_xlsx.modules.php.

◆ import_insert()

ImportXlsx::import_insert ( $arrayrecord,
$array_match_file_to_database,
$objimport,
$maxfields,
$importid,
$updatekeys )

Insert a record into database.

Parameters
array<int,array{val:mixed,type:int}>|bool$arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
array<int|string,string>$array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]...
Object$objimportObject import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...)
int$maxfieldsMax number of fields to use
string$importidImport key
string[]$updatekeysArray of keys to use to try to do an update first before insert. This field are defined into the module descriptor.
Returns
int Return integer <0 if KO, >0 if OK

Reimplemented from ModeleImports.

Definition at line 389 of file import_xlsx.modules.php.

References dol_include_once(), dol_print_error(), dol_stringtotime(), dol_syslog(), dol_trunc(), getDolGlobalString(), ModeleImports\getElementFromTableWithPrefix(), num2Alpha(), price2num(), and testSqlAndScriptInject().

◆ import_open_file()

ImportXlsx::import_open_file ( $file)

Open input file.

Parameters
string$filePath of filename
Returns
int Return integer <0 if KO, >=0 if OK

Reimplemented from ModeleImports.

Definition at line 261 of file import_xlsx.modules.php.

References dol_syslog().

◆ import_read_header()

ImportXlsx::import_read_header ( )

Input header line from file.

Returns
int Return integer <0 if KO, >=0 if OK

Reimplemented from ModeleImports.

Definition at line 306 of file import_xlsx.modules.php.

◆ import_read_record()

ImportXlsx::import_read_record ( )

Return array of next record in input file.

Returns
array|boolean Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string)

Reimplemented from ModeleImports.

Definition at line 327 of file import_xlsx.modules.php.

References dol_strlen().

◆ write_footer_example()

ImportXlsx::write_footer_example ( $outputlangs)

Output footer of an example file for this format.

Parameters
Translate$outputlangsOutput language
Returns
string String output

Definition at line 237 of file import_xlsx.modules.php.

◆ write_header_example()

ImportXlsx::write_header_example ( $outputlangs)

Output header of an example file for this format.

Parameters
Translate$outputlangsOutput language
Returns
string Empty string

Definition at line 166 of file import_xlsx.modules.php.

◆ write_record_example()

ImportXlsx::write_record_example ( $outputlangs,
$contentlinevalues )

Output record of an example file for this format.

Parameters
Translate$outputlangsOutput language
mixed[]$contentlinevaluesArray of lines
Returns
string Empty string

Definition at line 217 of file import_xlsx.modules.php.

◆ write_title_example()

ImportXlsx::write_title_example ( $outputlangs,
$headerlinefields )

Output title line of an example file for this format.

Parameters
Translate$outputlangsOutput language
string[]$headerlinefieldsArray of fields name
Returns
string String output

Definition at line 191 of file import_xlsx.modules.php.


The documentation for this class was generated from the following file: