//Initialize the graph
PXGraph graph = new PXGraph();
//Get the import process from the graph
PXImportAttribute importer = (PXImportAttribute)PXCache.GetImport();
//Load the records from the Excel file into the cache
var rows = importer.LoadDataFromFile(graph, fileBytes, PX.SM.FileExistsAction.ThrowException);
//Process the rows to ensure they meet your requirements
var processedRows = importer.ProcessData(graph, rows);
//Validate the processed rows
var validatedRows = importer.GetValidatedRecords(processedRows);
//Insert the validated rows into the cache
importer.LoadValidatedCacheData(validatedRows);
//Commit the changes to the database
graph.Actions.PressSave();
这段代码将通过代码的方式执行导入操作,并且会输出详细的错误信息。从输出的信息中,你可以找到Excel导入过程中出现的错误并对其进行修复。