SDK
Excel

Functions

int SPI_GEN_read_integer_cell_excel (int line, int row, int *iVal)
 Reads the content of an integer cell on the current sheet.
 
int SPI_GEN_read_real_cell_excel (int line, int row, double *rVal)
 Reads the contents of a real cell on the current sheet.
 
int SPI_GEN_read_string_cell_excel (int line, int row, std::string &sVal)
 Reads the content of a string cell from the current sheet.
 
int SPI_GEN_write_string_cell_excel (int line, int row, const std::string &sVal)
 Writes a string to the current cell.
 
int SPI_GEN_write_integer_cell_excel (int line, int row, int iVal)
 Writes an integer to the current cell.
 
int SPI_GEN_write_real_cell_excel (int line, int row, double rVal)
 Writes a real to the current cell.
 
int SPI_GEN_open_file_excel (const std::string &dir, const std::string &workbook, const std::string &worksheet)
 Opens an Excel workbook and select a current sheet.
 
int SPI_GEN_open_file_excel_read_write (const std::string &dir, const std::string &workbook, const std::string &worksheet)
 Opens an Excel workbook and select a current sheet.
 
int SPI_GEN_save_file_excel ()
 Saves the current Excel workbook.
 
void SPI_GEN_close_file_excel ()
 Closes Excel workbook.
 
int SPI_GEN_read_number_cell_excel (int *numberRows, int *numberColumns)
 Reads the number of rows and columns in an Excel workbook.
 

Detailed Description

Excel features

Function Documentation

◆ SPI_GEN_close_file_excel()

void SPI_GEN_close_file_excel ( )

Closes Excel workbook.

Version
4.4
Remarks
Do not forget to save the Excel workbook before if changes have been made
This function just close the current Excel workbook
void SPI_GEN_close_file_excel()
Closes Excel workbook.
Definition sp_gen02.c:421
See also
SPI_GEN_open_file_excel, SPI_GEN_open_file_excel_read_write

◆ SPI_GEN_open_file_excel()

int SPI_GEN_open_file_excel ( const std::string & dir,
const std::string & workbook,
const std::string & worksheet )

Opens an Excel workbook and select a current sheet.

Version
4.4
Parameters
[in]dirExcel workbook directory
[in]workbookname of Excel workbook to load
[in]worksheetworksheet name to select (empty string => First sheet)
Returns
SPI_YES if Ok | SPI_NO if error (Excel or not file)
Remarks
Automatic closing of the last open Excel workbook
Opens Excel file in read only mode
ier := ICALL(SPI_GEN_open_file_excel,'c:\dir_xl','toto.XLS','');
or
ier := ICALL(SPI_GEN_open_file_excel,'c:\dir_xl','toto.XLS','sheet2');
int SPI_GEN_open_file_excel(const std::string &dir, const std::string &workbook, const std::string &worksheet)
Opens an Excel workbook and select a current sheet.
Definition sp_gen02.c:298
See also
SPI_GEN_close_file_excel

◆ SPI_GEN_open_file_excel_read_write()

int SPI_GEN_open_file_excel_read_write ( const std::string & dir,
const std::string & workbook,
const std::string & worksheet )

Opens an Excel workbook and select a current sheet.

Version
6.05.207
Parameters
[in]dirExcel workbook directory
[in]workbookname of Excel workbook to load
[in]worksheetworksheet name to select (empty string => First sheet)
Returns
SPI_YES if Ok | SPI_NO if error (Excel or not file)
Remarks
Automatic closing of the last open Excel workbook
Opens Excel file in read and write mode
ier := ICALL(SPI_GEN_open_file_excel_read_write,'c:\dir_xl','toto.XLS','');
or
ier := ICALL(SPI_GEN_open_file_excel_read_write,'c:\dir_xl','toto.XLS','sheet2');
int SPI_GEN_open_file_excel_read_write(const std::string &dir, const std::string &workbook, const std::string &worksheet)
Opens an Excel workbook and select a current sheet.
Definition sp_gen02.c:345
See also
SPI_GEN_close_file_excel

◆ SPI_GEN_read_integer_cell_excel()

int SPI_GEN_read_integer_cell_excel ( int line,
int row,
int * iVal )

Reads the content of an integer cell on the current sheet.

Version
4.4
Parameters
[in]lineline containing the cell to read
[in]rowrow containing the cell to read
[out]iValinteger of the current cell
Returns
SPI_YES if Ok | SPI_NO if error (Excel or not file)
Remarks
Don't forget to open an Excel workbook
ier := ICALL(SPI_GEN_read_integer_cell_excel,1,2,ival);
int SPI_GEN_read_integer_cell_excel(int line, int row, int *iVal)
Reads the content of an integer cell on the current sheet.
Definition sp_gen02.c:41
See also
SPI_GEN_open_file_excel, SPI_GEN_open_file_excel_read_write

◆ SPI_GEN_read_number_cell_excel()

int SPI_GEN_read_number_cell_excel ( int * numberRows,
int * numberColumns )

Reads the number of rows and columns in an Excel workbook.

Version
4.4
Parameters
[out]numberRowsnumber of rows in the workbook
[out]numberColumnsnumber of columns in the workbook
Returns
SPI_YES if Ok | SPI_NO if error (Excel or file not present)
Remarks
Don't forget to open an Excel workbook
ier := ICALL(SPI_GEN_read_number_cell_excel,nb_rows,nb_columns);
int SPI_GEN_read_number_cell_excel(int *numberRows, int *numberColumns)
Reads the number of rows and columns in an Excel workbook.
Definition sp_gen02.c:450
See also
SPI_GEN_open_file_excel, SPI_GEN_open_file_excel_read_write

◆ SPI_GEN_read_real_cell_excel()

int SPI_GEN_read_real_cell_excel ( int line,
int row,
double * rVal )

Reads the contents of a real cell on the current sheet.

Version
4.4
Parameters
[in]lineline containing the cell to read
[in]rowrow containing the cell to read
[out]rValreal value of the current cell
Returns
SPI_YES if Ok | SPI_NO if error (Excel or not file)
Remarks
Don't forget to open an Excel workbook
ier := ICALL(SPI_GEN_read_real_cell_excel,1,2,rval);
int SPI_GEN_read_real_cell_excel(int line, int row, double *rVal)
Reads the contents of a real cell on the current sheet.
Definition sp_gen02.c:86
See also
SPI_GEN_open_file_excel

◆ SPI_GEN_read_string_cell_excel()

int SPI_GEN_read_string_cell_excel ( int line,
int row,
std::string & sVal )

Reads the content of a string cell from the current sheet.

Version
4.4
Parameters
[in]lineline containing the cell to read
[in]rowrow containing the cell to read
[out]sValstring value of the current cell
Returns
SPI_YES if Ok | SPI_NO if error (Excel or not file)
Remarks
Don't forget to open an Excel workbook
ier := ICALL(SPI_GEN_read_string_cell_excel,1,2,sval);
int SPI_GEN_read_string_cell_excel(int line, int row, std::string &sVal)
Reads the content of a string cell from the current sheet.
Definition sp_gen02.c:130
See also
SPI_GEN_open_file_excel

◆ SPI_GEN_save_file_excel()

int SPI_GEN_save_file_excel ( )

Saves the current Excel workbook.

Version
6.05.207
Returns
SPI_YES if Ok | SPI_NO if error (Excel or file not present)
Remarks
Open the workbook in read write before
int SPI_GEN_save_file_excel()
Saves the current Excel workbook.
Definition sp_gen02.c:388
See also
SPI_GEN_open_file_excel_read_write

◆ SPI_GEN_write_integer_cell_excel()

int SPI_GEN_write_integer_cell_excel ( int line,
int row,
int iVal )

Writes an integer to the current cell.

Version
6.05.207
Parameters
[in]lineline containing the cell to write
[in]rowrow containing the cell to write
[in]iValinteger to write in the cell
Returns
SPI_YES if Ok | SPI_NO if error (Excel or not file)
Remarks
Don't forget to open an Excel workbook
ier := ICALL(SPI_GEN_write_integer_cell_excel,1,2,121);
int SPI_GEN_write_integer_cell_excel(int line, int row, int iVal)
Writes an integer to the current cell.
Definition sp_gen02.c:215
See also
SPI_GEN_open_file_excel, SPI_GEN_open_file_excel_read_write

◆ SPI_GEN_write_real_cell_excel()

int SPI_GEN_write_real_cell_excel ( int line,
int row,
double rVal )

Writes a real to the current cell.

Version
6.05.207
Parameters
[in]lineline containing the cell to write
[in]rowrow containing the cell to write
[in]rValreal to write in the cell
Returns
SPI_YES if Ok | SPI_NO if error (Excel or not file)
Remarks
Don't forget to open an Excel workbook
ier := ICALL(SPI_GEN_write_real_cell_excel,1,2,10.054);
int SPI_GEN_write_real_cell_excel(int line, int row, double rVal)
Writes a real to the current cell.
Definition sp_gen02.c:256
See also
SPI_GEN_open_file_excel, SPI_GEN_open_file_excel_read_write

◆ SPI_GEN_write_string_cell_excel()

int SPI_GEN_write_string_cell_excel ( int line,
int row,
const std::string & sVal )

Writes a string to the current cell.

Version
6.05.207
Parameters
[in]lineline containing the cell to write
[in]rowrow containing the cell to write
[in]sValstring to write in the cell
Returns
SPI_YES if Ok | SPI_NO if error (Excel or not file)
Remarks
Don't forget to open an Excel workbook
ier := ICALL(SPI_GEN_write_string_cell_excel,1,2,'toto');
int SPI_GEN_write_string_cell_excel(int line, int row, const std::string &sVal)
Writes a string to the current cell.
Definition sp_gen02.c:173
See also
SPI_GEN_open_file_excel, SPI_GEN_open_file_excel_read_write