Quintiq file version 2.0
|
#parent: #root
|
Method Load (
|
LocalTable localTable
|
) const
|
{
|
TextBody:
|
[*
|
// rislai Jun-20-2024 (created)
|
file := OSFile::Construct();
|
recycleBin := localTable.RecycleBin();
|
|
columns := selectset( localTable,LocalColumn,column,true );
|
columnTree := NamedValueTree::Create();
|
for( i := 0 ; i < columns.Size(); i++ ){
|
column := columns.Element( i );
|
tempHandle := columnTree.GetHandle( column.Name() );
|
columnTree.Root().AddChild( tempHandle,i );
|
}
|
|
try {
|
file.Open( this.FilePath(), "Read", false );
|
webFileBinaryData := file.ReadBinary();
|
|
generalExcelImportAndExportDataSource := GeneralExcelImportAndExportDataSource::Upload( recycleBin, webFileBinaryData, this.Name() );
|
generalExcelImportAndExportDataSource.ReadStructure();
|
selections := selectset( generalExcelImportAndExportDataSource, GeneralExcelImportAndExportDataTable, tempGEIAEDT, true );
|
if( selections.Size() <> 0 ){
|
table := selections.Element( 0 );
|
generalColumns := selectset( table,GeneralExcelImportAndExportDataColumn,column,true );
|
|
// 生成列数据
|
for( i := 0; i< generalColumns.Size(); i++ ){
|
generalColumn := generalColumns.Element( i );
|
column := localTable.LocalColumn( relnew, Name := generalColumn.Name(),Index := generalColumn.ColumnIndex() );
|
columns.Add( column );
|
tempHandle := columnTree.GetHandle( column.Name() );
|
columnTree.Root().AddChild( tempHandle,columns.Size() - 1 );
|
}
|
|
// 生成数据
|
rowSize := table.GeneralExcelImportAndExportDataRow( relsize );
|
for ( rowIndex := 0; rowIndex < rowSize; rowIndex++ ) {
|
generalRow := select( table, GeneralExcelImportAndExportDataRow, tempGEIAEDR, tempGEIAEDR.RowNr() = rowIndex );
|
row := localTable.LocalRow( relnew,Index := rowIndex );
|
generalCells := selectsortedset( generalRow,GeneralExcelImportAndExportDataCell,cell,true,cell.GeneralExcelImportAndExportDataColumn().ColumnIndex() );
|
|
traverse( generalCells,Elements,generalCell ){
|
columnName := generalCell.GeneralExcelImportAndExportDataColumn().Name();
|
columnHandle := columnTree.GetHandle( columnName );
|
columnIndex := columnTree.Root().Child( columnHandle ).GetValueAsNumber();
|
column := columns.Element( columnIndex );
|
row.LocalCell( relnew,Value := generalCell.Value() ,LocalColumn := column );
|
}
|
}
|
}
|
// 后续删除
|
generalExcelImportAndExportDataSource.Delete();
|
file.Close();
|
} onerror {
|
if( not isnull( file )){
|
file.Close();
|
}
|
error( e );
|
}
|
*]
|
}
|