cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are happy to announce the new Windchill Customization board! Learn more.

How can I automate the "Load From Spreadsheet" action windchill 10.2 M030. Please suggest me API which can be helpful for this....Thanks in advance

cdeshpandey
1-Newbie

How can I automate the "Load From Spreadsheet" action windchill 10.2 M030. Please suggest me API which can be helpful for this....Thanks in advance

Please let me know the API to use..

2 REPLIES 2

Below is used in 10.1, hopefully works in 10.2, if not may need little modifications .

ImportJob job = new ImportJob();
ImportSpec importSpec = new ImportSpec();
WTContainer myContainer = part.getContainer();
ApplicationData appData =<Get you application Data Here, the spreadsheet attached to part/ doc etc..>
     importSpec.setContainerRef(WTContainerRef.newWTContainerRef(myContainer));
     importSpec.setAction(ImportAction.ADD_ONLY);
     importSpec.setPreview(true);
     importSpec.setFilename(appData.getFileName());

     job.setSpec(importSpec);
     job.setStatus(ImportJobStatus.DEFINING);
     OwnershipHelper.setOwner(job, SessionHelper.manager.getPrincipal());
     AdminDomainRef admindomainref = myContainer.getDefaultDomainReference();
     job.setDomainRef(admindomainref);
     job.setContainerReference(WTContainerRef.newWTContainerRef(myContainer));
     ImportJobEvent importjobevent = new ImportJobEvent(ImportJobEvent.CREATED, job);
     ImportExportEventHelper.service.dispatchVetoableEvent(importjobevent, importjobevent.getEventKey());

     job = (ImportJob) PersistenceHelper.manager.save(job);

     wt.content.ContentHolder contentHolder = (wt.content.ContentHolder) job;
     ApplicationData applicationData = ApplicationData.newApplicationData(contentHolder);
     applicationData.setRole(ContentRoleType.PRIMARY);
     applicationData.setFileName(appData.getFileName());

     ContentServerHelper.service.updateContent(contentHolder, applicationData, filePath);
     job = StandardImportService.importSpreadsheet(job.getPersistInfo().getObjectIdentifier());
    
     System.out.println("job status ---> "+job.getStatus().getDisplay());

Hi,

Thanks for helping.

It worrked fine in Windchill 10.2 M030 also.

Top Tags