Flex Sheet Failure to Paste from Excel

Posted by: oskarputraa on 13 December 2019, 12:30 am EST

  • Posted 13 December 2019, 12:30 am EST - Updated 3 October 2022, 6:33 pm EST

    Hi,

    I’m getting an error while trying to paste from excel.



    Here, the code I use

    
    <wj-flex-sheet #formatSheet (initialized)="formatSheetInit(formatSheet)"
             (selectionChanged)="onSelectionChanged(formatSheet,$event)"
             (cellEditEnded)="onSelectionChanged(formatSheet,$event)"
             (cellEditEnding)="onCellEditEnding(formatSheet,$event)"
             (rowEditStarting)="rowEditStarting(formatSheet ,$event)" 
             (contextmenu)="onRightClick($event)"
             [wjContextMenu]="ctmenu"
             (updatingView)="onUpdatingView(formatSheet)" (pasted)="updateSheet(formatSheet, $event)"
             style="margin:0px;border:0px;width:100%;height:77vh;padding:0">
             <wj-sheet [itemsSource]="source" name="{{sheetTitle}}"></wj-sheet>
          </wj-flex-sheet><br>
    
    
    
    updateSheet(s, e) {
    
    		console.log("UPDATE SHEET");
    
    		var updatedData: string = JSON.stringify(this.source.sourceCollection);
    		if (this.isImportExcel) {
    			const newData = this.getImportedCVData();
    
    			console.log("NEW DATAAAAAAAAAAAAAAAAAAAAAAAAAAA");
    			console.log(newData);
    
    			this.source.sourceCollection = newData;
    			updatedData = String(JSON.stringify(this.source.sourceCollection).replace(/'/g, ""));
    
    		}
    
    		this.apiService.saveSheet(this.idGrid, updatedData).subscribe(res => {
    			var resp: any = res;
    
    			console.log(res);
    			if (resp.success) {
    				this.socket.emit('sheet', {
    					data: this.formatSheet.getCellData(e.row, e.col, false),
    					id: this.idGrid,
    					row: e.row,
    					column: e.col
    				}, function (data) {
    					console.log("NEW DATA !!");
    				});
    			}
    		}, err => {
    			console.log(err);
    		});
    
    		this.checkEditedCell = false; // Assign False Edited
    
    
    	}
    
    

    Could you please help me with that ?

    Thanks,

    Oskar Putra

  • Posted 13 December 2019, 12:53 am EST

    an error occurs when I paste multiple line.

    “Halo

    there

    hai”

    And normal when I paste single line

    “Halo there hai”

  • Posted 16 December 2019, 12:08 am EST

    Hi Oskar,

    From the console error, it looks like your instance of the Sheet object of the FlexSheet is null. Could you please explain more about the function you are performing in the pasted event.

    As per my understanding, it looks like you are trying to recreate the data source of the FlexSheet after pasting. Is my understanding correct?

    Regards,

    Ashwin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels